public bool SaveImages(int index, int count, Func <int, string> getFileName, Action <int, string, Progress> callBack, CancelToken token) { var total = index + count; for (var i = index; i < total; i++) { var fileName = getFileName(i); lock (_syncObject) //当外界有多线程访问时,此处解决并发冲突 { if (!File.Exists(fileName)) { SaveImage(i, fileName); } } var g = new Progress(this.PageCount, i + 1); callBack(i, fileName, g); if (token.IsCancelled || _isCancelled) { return(false); } } return(true); }
public bool ExtractImages(int index, int count, Action <int, Stream, Progress> callBack, CancelToken token) { var total = index + count; for (var i = index; i < total; i++) { using (var content = ExtractImage(i)) { var g = new Progress(this.PageCount, i + 1); callBack(i, content, g); } if (token.IsCancelled || _isCancelled) { return(false); } } return(true); }
public bool ExtractImages(int index, int count, Action <int, Stream, Progress> callBack, CancelToken token) { return(_document.ExtractImages(index, count, callBack, token)); }
public bool SaveImages(int index, int count, Func <int, string> getFileName, Action <int, string, Progress> callBack, CancelToken token) { return(_document.SaveImages(index, count, getFileName, callBack, token)); }
public void ExtractImages(int index, int count, Action <int, Stream, Progress> callBack, CancelToken token) { var total = index + count; for (var i = index; i < total; i++) { using (var content = ExtractImage(i)) { var g = new Progress(this.PageCount, i + 1); callBack(i, content, g); } if (token.IsCanceled) { break; } } }