Пример #1
0
        protected async Task DoWorkAsync(IQueueEntry <SimpleWorkItem> w, AsyncCountdownEvent countdown, WorkInfo info)
        {
            _logger.Trace($"Starting: {w.Value.Id}");
            Assert.Equal("Hello", w.Value.Data);

            try {
                // randomly complete, abandon or blowup.
                if (RandomData.GetBool())
                {
                    _logger.Trace($"Completing: {w.Value.Id}");
                    await w.CompleteAsync();

                    info.IncrementCompletedCount();
                }
                else if (RandomData.GetBool())
                {
                    _logger.Trace($"Abandoning: {w.Value.Id}");
                    await w.AbandonAsync();

                    info.IncrementAbandonCount();
                }
                else
                {
                    _logger.Trace($"Erroring: {w.Value.Id}");
                    info.IncrementErrorCount();
                    throw new Exception();
                }
            } finally {
                _logger.Trace($"Signal {countdown.CurrentCount}");
                countdown.Signal();
            }
        }
Пример #2
0
        protected void DoWork(QueueEntry <SimpleWorkItem> w, CountdownEvent latch, WorkInfo info)
        {
            Trace.WriteLine(String.Format("Starting: {0}", w.Value.Id));
            Assert.Equal("Hello", w.Value.Data);

            try {
                // randomly complete, abandon or blowup.
                if (RandomData.GetBool())
                {
                    Trace.WriteLine(String.Format("Completing: {0}", w.Value.Id));
                    w.Complete();
                    info.IncrementCompletedCount();
                }
                else if (RandomData.GetBool())
                {
                    Trace.WriteLine(String.Format("Abandoning: {0}", w.Value.Id));
                    w.Abandon();
                    info.IncrementAbandonCount();
                }
                else
                {
                    Trace.WriteLine(String.Format("Erroring: {0}", w.Value.Id));
                    info.IncrementErrorCount();
                    throw new ApplicationException();
                }
            } finally {
                latch.Signal();
            }
        }
Пример #3
0
        protected void DoWork(QueueEntry<SimpleWorkItem> w, CountdownEvent latch, WorkInfo info)
        {
            Trace.WriteLine($"Starting: {w.Value.Id}");
            Assert.Equal("Hello", w.Value.Data);

            try {
                // randomly complete, abandon or blowup.
                if (RandomData.GetBool()) {
                    Trace.WriteLine($"Completing: {w.Value.Id}");
                    w.Complete();
                    info.IncrementCompletedCount();
                } else if (RandomData.GetBool()) {
                    Trace.WriteLine($"Abandoning: {w.Value.Id}");
                    w.Abandon();
                    info.IncrementAbandonCount();
                } else {
                    Trace.WriteLine($"Erroring: {w.Value.Id}");
                    info.IncrementErrorCount();
                    throw new ApplicationException();
                }
            } finally {

                Trace.WriteLine($"Signal {latch.CurrentCount}");
                latch.Signal();
            }
        }
Пример #4
0
        protected async Task DoWorkAsync(QueueEntry<SimpleWorkItem> w, AsyncCountdownEvent countdown, WorkInfo info) {
            Trace.WriteLine($"Starting: {w.Value.Id}");
            Assert.Equal("Hello", w.Value.Data);

            try {
                // randomly complete, abandon or blowup.
                if (RandomData.GetBool()) {
                    Trace.WriteLine($"Completing: {w.Value.Id}");
                    await w.CompleteAsync();
                    info.IncrementCompletedCount();
                } else if (RandomData.GetBool()) {
                    Trace.WriteLine($"Abandoning: {w.Value.Id}");
                    await w.AbandonAsync();
                    info.IncrementAbandonCount();
                } else {
                    Trace.WriteLine($"Erroring: {w.Value.Id}");
                    info.IncrementErrorCount();
                    throw new ApplicationException();
                }
            } finally {
                Trace.WriteLine($"Signal {countdown.CurrentCount}");
                countdown.Signal();
            }
        }