示例#1
0
        public Action Register(Action <TParameter> a)
        {
            var callback = WeakCallback <TParameter> .Create(this, (obj, val) => a(val));

            Register(callback);
            return(() => Deregister(callback));
        }
示例#2
0
        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));
        }
示例#3
0
 public void Deregister(WeakCallback <TParameter> a)
 {
     m_callbacks.RemoveAll(b => b == a || b.Expired);
 }
示例#4
0
 public Action Register(WeakCallback <TParameter> a)
 {
     m_callbacks.RemoveAll(b => b.Expired);
     m_callbacks.Add(a);
     return(() => Deregister(a));
 }
示例#5
0
        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);
        }