예제 #1
0
        public static T WaitForMessage <T>(this IMessagingHub hub, Func <T, bool> filter, Action action, int wait = 5000)
        {
            var condition = new MessageWaitCondition <T>(filter);

            hub.AddListener(condition);
            action();

            try
            {
                return(condition.Wait(wait));
            }
            finally
            {
                hub.RemoveListener(condition);
            }
        }
예제 #2
0
 public void Receive(T message)
 {
     _task.SetResult(message);
     _messaging.RemoveListener(this);
 }
 public void Receive(SystemRecycled message)
 {
     _completion.SetResult(message);
     _messaging.RemoveListener(this);
 }