示例#1
0
        public void RunNow()
        {
            if (_latch.Latched)
            {
                return;
            }

            TaskCompletionSource <object>[] waiters = null;

            lock (_waiterLock)
            {
                waiters = _waiters.ToArray();
                _waiters.Clear();
            }

            try
            {
                _bus.Consume(new JobRequest <TJob>());
                waiters.Each(x => x.SetResult(new object()));
            }
            catch (Exception e)
            {
                _waiters.Each(x => x.SetException(e));

                // VERY unhappy with the code below, but I cannot determine
                // why the latching doesn't work cleanly in the NUnit console runner
                if (_latch.Latched || e.Message.Contains("Could not find an Instance named"))
                {
                    return;
                }

                if (!_latch.Latched)
                {
                    _logger.FailedToSchedule(typeof(TJob), e);
                }
            }
            finally
            {
                _timer.Interval = Interval;
            }
        }