void PerformCopy (string target_dir) { double? total_bytes = null; var progress = new ProgressInteraction ("Copying", ComputeTotalFiles (), total_bytes); var runstate = Application.Begin (progress); using (var copyOperation = new CopyOperation (progress)){ #if !DEBUG var timer = Application.MainLoop.AddTimeout (TimeSpan.FromSeconds (1), mainloop => { progress.UpdateStatus (copyOperation); return true; }); Task t = Task.Factory.StartNew (delegate { #endif foreach (var node in Selection ()){ bool isDir = node is Listing.DirNode; var r = copyOperation.Perform (CurrentPath, listing.GetPathAt (node.StartIdx), isDir, node.Info.Protection, target_dir); if (r == FileOperation.Result.Cancel) break; } #if !DEBUG Application.Stop (); }, null); Application.RunLoop (runstate, true); Application.MainLoop.RemoveTimeout (timer); #endif } Application.End (runstate); }
public void UpdateStatus(CopyOperation copyOperation) { int processedFiles; double processedBytes; long fileSize, fileProgress; lock (copyOperation) { processedFiles = copyOperation.ProcessedFiles; processedBytes = copyOperation.ProcessedBytes; fileSize = copyOperation.CurrentFileSize; fileProgress = copyOperation.CurrentFileProgress; } var progress = fileSize > 0 ? (fileProgress / (double)fileSize) : 0.0; filePct.Text = String.Format("Called: {0}", calls++); //pct (progress); if (Count != 1) { progress = processedFiles / (double)Count; countPct.Text = pct(progress); } if (ByteCount.HasValue) { progress = processedBytes / ByteCount.Value; bytesPct.Text = pct(progress); } Terminal.Refresh(); }
public void UpdateStatus(CopyOperation copyOperation) { int processedFiles; double processedBytes; long fileSize, fileProgress; lock (copyOperation){ processedFiles = copyOperation.ProcessedFiles; processedBytes = copyOperation.ProcessedBytes; fileSize = copyOperation.CurrentFileSize; fileProgress = copyOperation.CurrentFileProgress; } var progress = fileSize > 0 ? (fileProgress / (double) fileSize) : 0.0; filePct.Text = String.Format ("Called: {0}", calls++); //pct (progress); if (Count != 1){ progress = processedFiles / (double) Count; countPct.Text = pct (progress); } if (ByteCount.HasValue){ progress = processedBytes / ByteCount.Value; bytesPct.Text = pct (progress); } Application.Refresh (); }