Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
 public bool ExtractImages(int index, int count, Action <int, Stream, Progress> callBack, CancelToken token)
 {
     return(_document.ExtractImages(index, count, callBack, token));
 }
Ejemplo n.º 4
0
 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));
 }
Ejemplo n.º 5
0
        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;
                }
            }
        }