public Action Register(Action <TParameter> a) { var callback = WeakCallback <TParameter> .Create(this, (obj, val) => a(val)); Register(callback); return(() => Deregister(callback)); }
public Action Register <THost>(THost host, Action <THost, TParameter> callback) where THost : class { var callback2 = (WeakCallback <TParameter> .Create(host, callback)); Register(callback2); return(() => Deregister(callback2)); }
public void Deregister(WeakCallback <TParameter> a) { m_callbacks.RemoveAll(b => b == a || b.Expired); }
public Action Register(WeakCallback <TParameter> a) { m_callbacks.RemoveAll(b => b.Expired); m_callbacks.Add(a); return(() => Deregister(a)); }
public static Action <TParameter> Handler <TObject>(TObject o, Action <TObject, TParameter> callback) where TObject : class { var weak = WeakCallback <TParameter> .Create(o, callback); return(weak.Execute); }