Example #1
0
        private void FileOperationOnRetryStarted(object sender, FileOperationRetryStartedEventArgs e)
        {
            // Using a ThreadPool thread so that the caller is not blocked
            ThreadPool.QueueUserWorkItem(RetryIntervalProgressProc);

            void RetryIntervalProgressProc(object state)
            {
                var timer  = Stopwatch.StartNew();
                var format = $"{EscapeCodes.SavePosition()}{{0}}{EscapeCodes.RestorePosition()}";

                ZCopyOutput.PrintError(e.Reason.Message + " " + e.Reason.InnerException?.Message, false);

                while (timer.ElapsedMilliseconds < e.RetryInterval.TotalMilliseconds)
                {
                    ZCopyOutput.Print(format, $"Retrying in {e.RetryInterval - timer.Elapsed:mm\\mss\\s}");
                }

                timer.Stop();
                ZCopyOutput.Print();
            }
        }
 public static StringBuilder RestorePosition(this StringBuilder sb)
 {
     return(sb.Append(EscapeCodes.RestorePosition()));
 }