예제 #1
0
        public Task <T> WaitForMessage <T>(int timeout = 5000)
        {
            var waiter = new MessageWaiter <T>(m => true, timeout);

            _waiters.Add(waiter);
            var message = _replyMessages.FirstOrDefault();

            if (message != null)
            {
                waiter.Done(message);
            }
            return(waiter.ToTask());
        }
예제 #2
0
        public Task <T> WaitForMessage <T>(Func <T, bool> specification, int timeout = 5000)
        {
            var waiter = new MessageWaiter <T>(specification, timeout);

            _waiters.Add(waiter);
            var message = _replyMessages.OfType <T>()
                          .FirstOrDefault(specification);

            if (message != null)
            {
                waiter.Done(message);
            }
            return(waiter.ToTask());
        }