You've already forked linux-packaging-mono
Imported Upstream version 6.4.0.137
Former-commit-id: 943baa9f16a098c33e129777827f3a9d20da00d6
This commit is contained in:
parent
e9207cf623
commit
ef583813eb
39
mcs/class/System.Private.CoreLib/System/WeakReference.T.cs
Normal file
39
mcs/class/System.Private.CoreLib/System/WeakReference.T.cs
Normal file
@ -0,0 +1,39 @@
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace System
|
||||
{
|
||||
partial class WeakReference<T>
|
||||
{
|
||||
GCHandle handle;
|
||||
bool trackResurrection;
|
||||
|
||||
T Target {
|
||||
get {
|
||||
GCHandle h = handle;
|
||||
return h.IsAllocated ? (T) h.Target : null;
|
||||
}
|
||||
}
|
||||
|
||||
~WeakReference ()
|
||||
{
|
||||
handle.Free ();
|
||||
}
|
||||
|
||||
void Create (T target, bool trackResurrection)
|
||||
{
|
||||
if (trackResurrection) {
|
||||
trackResurrection = true;
|
||||
handle = GCHandle.Alloc (target, GCHandleType.WeakTrackResurrection);
|
||||
} else {
|
||||
handle = GCHandle.Alloc (target, GCHandleType.Weak);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetTarget (T target)
|
||||
{
|
||||
handle.Target = target;
|
||||
}
|
||||
|
||||
bool IsTrackResurrection () => trackResurrection;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user