Ejemplo n.º 1
0
        private static async Task LastStageAsync(Completeble <string> message)
        {
            try
            {
                await Task.Delay(1000);

                if (Environment.TickCount % 4 == 0)
                {
                    throw new ArgumentOutOfRangeException("4th");
                }

                string next = $"{message.Value} -> last stage";

                var nextMessage = message.ProceedWith(next);
                if (!nextMessage.TryComplete())
                {
                    Console.WriteLine("Completion failed (can only complete once)");
                }
            }
            catch (Exception ex)
            {
                // don't take the entire consumer down
                message.TryCompleteAsFaulted(ex);
            }
        }
Ejemplo n.º 2
0
        private static async Task ProcessFinalStageAsync(Completeble <string> message)
        {
            await Task.Delay(1000);

            string next = $"{message.Value} -> last stage";

            var nextMessage = message.ProceedWith(next);

            if (!nextMessage.TryComplete())
            {
                Console.WriteLine("Completion failed (can only complete once)");
            }
        }