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
44
mcs/class/System.Private.CoreLib/System/WeakReference.cs
Normal file
44
mcs/class/System.Private.CoreLib/System/WeakReference.cs
Normal file
@ -0,0 +1,44 @@
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace System
|
||||
{
|
||||
partial class WeakReference
|
||||
{
|
||||
bool trackResurrection;
|
||||
GCHandle handle;
|
||||
|
||||
public virtual bool IsAlive {
|
||||
get {
|
||||
return Target != null;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual object Target {
|
||||
get {
|
||||
if (!handle.IsAllocated)
|
||||
return null;
|
||||
return handle.Target;
|
||||
}
|
||||
set {
|
||||
handle.Target = value;
|
||||
}
|
||||
}
|
||||
|
||||
~WeakReference ()
|
||||
{
|
||||
handle.Free ();
|
||||
}
|
||||
|
||||
void Create (object target, bool trackResurrection)
|
||||
{
|
||||
if (trackResurrection) {
|
||||
this.trackResurrection = true;
|
||||
handle = GCHandle.Alloc (target, GCHandleType.WeakTrackResurrection);
|
||||
} else {
|
||||
handle = GCHandle.Alloc (target, GCHandleType.Weak);
|
||||
}
|
||||
}
|
||||
|
||||
bool IsTrackResurrection () => trackResurrection;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user