Exemplo n.º 1
0
        /// <summary>
        /// Helper method for <see cref="CallCenter2Demo"/>.
        /// </summary>
        private static void ConsultantAction(ICallCenter callCenter, string consultantName, ConsoleColor foregroundColor, CancellationToken ct = default(CancellationToken))
        {
            while (true)
            {
                if (ct.IsCancellationRequested)
                {
                    return;
                }

                var call = callCenter.Answer(consultantName);

                if (call != null)
                {
                    foregroundColor.UseFore(() =>
                                            $"Call #{call.Id} from {call.ClientId} is answered by {call.Consultant}.".Log()
                                            );

                    Thread.Sleep(_random.Next(1000, 10000));

                    callCenter.End(call);

                    foregroundColor.UseFore(() =>
                                            $"Call #{call.Id} from {call.ClientId} is ended by {call.Consultant}.".Log()
                                            );

                    Thread.Sleep(_random.Next(500, 1000));
                }
                else
                {
                    Thread.Sleep(100);
                }
            }
        }