private void NotifyCompletion(CopyFileContext context) { instance.BeginResumeBookmark(context.Bookmark, context.Exception, (a) => instance.EndResumeBookmark(a), null); if (contexts.TryRemove(context.Bookmark.Name, out context)) { context.Action = CopyFileAction.Stop; } }
public bool Resume(Bookmark bookmark, FileInfo source, FileInfo destination, Statements.FileCopyOptions options, int stepIncrement) { var context = new CopyFileContext(stepIncrement) { Instance = this, Bookmark = bookmark, Action = CopyFileAction.Continue }; if (contexts.TryAdd(bookmark.Name, context)) { var action = new Action(() => ExecuteCopyFile(context, source, destination, options)); action.BeginInvoke((a) => { try { action.EndInvoke(a); } catch (Exception ex) { ((CopyFileContext)a.AsyncState).Exception = ex; } finally { ((CopyFileContext)a.AsyncState).NotifyCompletion(); } }, context); return true; } return false; }
public bool Resume(Bookmark bookmark, FileInfo source, FileInfo destination, Statements.FileCopyOptions options, int stepIncrement) { var context = new CopyFileContext(stepIncrement) { Instance = this, Bookmark = bookmark, Action = CopyFileAction.Continue }; if (contexts.TryAdd(bookmark.Name, context)) { var action = new Action(() => ExecuteCopyFile(context, source, destination, options)); action.BeginInvoke((a) => { try { action.EndInvoke(a); } catch (Exception ex) { ((CopyFileContext)a.AsyncState).Exception = ex; } finally { ((CopyFileContext)a.AsyncState).NotifyCompletion(); } }, context); return(true); } return(false); }
private void NotifyCompletion(CopyFileContext context) { instance.BeginResumeBookmark(context.Bookmark, context.Exception, (a) => instance.EndResumeBookmark(a), null); if (contexts.TryRemove(context.Bookmark.Name, out context)) context.Action = CopyFileAction.Stop; }
private void HandleProgress(CopyFileContext context, FileInfo source, FileInfo destination, int progress) { instance.BeginResumeBookmark(context.Bookmark, progress, (a) => instance.EndResumeBookmark(a), null); }
private void ExecuteCopyFile(CopyFileContext context, FileInfo source, FileInfo destination, Statements.FileCopyOptions options) { FileCopyHelper.CopyFile(source, destination, options, new CopyFileHandler((s, t, st, sz, tr) => ((CopyFileContext)st).HandleProgress(s, t, sz, tr)), context); }