Ejemplo n.º 1
0
 private static void TrackProgress(TlcEnvironment env, CancellationToken ct)
 {
     try
     {
         while (!ct.IsCancellationRequested)
         {
             // Print a dot every 0.6s, which will make 50 dots take 30 seconds.
             // REVIEW: maybe an adaptive interval that would expand if nothing happens is a better idea.
             TimeSpan interval = TimeSpan.FromSeconds(0.6);
             if (ct.WaitHandle.WaitOne(interval))
             {
                 // Cancellation was requested.
                 return;
             }
             env.PrintProgress();
         }
     }
     catch (Exception ex)
     {
         Console.Error.WriteLine("Progress tracking terminated with an exception");
         PrintExceptionData(Console.Error, ex, false);
         Console.Error.WriteLine("Progress tracking is terminated.");
     }
 }