mirror of
https://github.com/mirror/processhacker
synced 2026-06-08 16:03:24 +00:00
b02427417c
git-svn-id: svn://svn.code.sf.net/p/processhacker/code@5614 21ef857c-d57f-4fe0-8362-d861dc6d29cd
40 lines
887 B
C#
40 lines
887 B
C#
using System;
|
|
|
|
namespace ProcessHacker.Common
|
|
{
|
|
public class WeakReference<T>
|
|
where T : class
|
|
{
|
|
public static implicit operator T(WeakReference<T> reference)
|
|
{
|
|
return reference.Target;
|
|
}
|
|
|
|
private WeakReference _weakReference;
|
|
|
|
public WeakReference(T obj)
|
|
: this(obj, false)
|
|
{ }
|
|
|
|
public WeakReference(T obj, bool trackResurrection)
|
|
{
|
|
_weakReference = new WeakReference(obj, trackResurrection);
|
|
}
|
|
|
|
public bool Alive
|
|
{
|
|
get { return _weakReference.IsAlive; }
|
|
}
|
|
|
|
public bool TrackResurrection
|
|
{
|
|
get { return _weakReference.TrackResurrection; }
|
|
}
|
|
|
|
public T Target
|
|
{
|
|
get { return _weakReference.Target as T; }
|
|
}
|
|
}
|
|
}
|