Psst.. new poll here.
[email protected] webmail now available. Want one? Go here.
Cannot use outlook/hotmail/live here to register as they blocking our mail servers. #microsoftdeez
Obey the Epel!
Paste
Pasted as C# by folex ( 11 years ago )
public class WeakEventHandler
{
object strongTargetReference;
WeakReference weakTargetReference;
MethodInfo method;
public WeakEventHandler (Action action)
{
strongTargetReference = action.Target;
method = action.Method;
}
public void Invoke ()
{
if (strongTargetReference != null)
method.Invoke (strongTargetReference, null);
}
public void MakeWeak ()
{
weakTargetReference = new WeakReference (strongTargetReference);
strongTargetReference = null;
}
}
Revise this Paste