コード例 #1
0
 public Task Subscribe(object owner, Func <Task> callback)
 {
     lock (_mutex)
     {
         _handlers += (owner, callback);
     }
     return(callback());
 }
コード例 #2
0
ファイル: AsyncEventT.cs プロジェクト: kobi2294/MvvmKit
        public AsyncEvent(T initValue = default(T))
        {
            _handlers = new ContextMulticastFuncTask <T>();

            // by default, on subscribe we notify with the latest value
            _onSubscribe = async(cb) =>
            {
                await cb(LatestValue);
            };

            LatestValue = initValue;
        }
コード例 #3
0
 public Task Unsubscribe(object owner, Func <Task> callback = null)
 {
     if (callback == null)
     {
         lock (_mutex)
         {
             _handlers -= owner;
         }
     }
     else
     {
         lock (_mutex)
         {
             _handlers -= (owner, callback);
         }
     }
     return(Tasks.Empty);
 }
コード例 #4
0
 public AsyncEvent()
 {
     _handlers = new ContextMulticastFuncTask();
 }