Exemple #1
0
 public void MonitorAndLogTrades()
 {
     foreach (var nextTrade in _tradesToLog.GetConsumingEnumerable())
     {
         _staffLogs.LogTrade(nextTrade);
         Console.WriteLine($"Processing transaction from {nextTrade.Person.Name}");
     }
 }
Exemple #2
0
 public void MonitorAndLogTrades()
 {
     while (true)
     {
         try
         {
             Trade nextTrade = _tradesToLog.Take();
             _staffLogs.LogTrade(nextTrade);
             Console.WriteLine($"Processing trade from {nextTrade.Person.Name}");
         }
         catch (InvalidOperationException ex)
         {
             Console.WriteLine(ex.Message);
             return;
         }
     }
 }
Exemple #3
0
 public void MonitorAndLogTrades()
 {
     while (true)
     {
         Trade nextTrade;
         bool  done = _tradesToLog.TryTake(out nextTrade);
         if (done)
         {
             _staffLogs.LogTrade(nextTrade);
             Console.WriteLine(
                 $"Processing transaction from {nextTrade.Person.Name}");
         }
         else if (_workingDayComplete)
         {
             Console.WriteLine("No more sales to log - exiting");
             return;
         }
         else
         {
             Console.WriteLine("No transactions available");
             Thread.Sleep(500);
         }
     }
 }