Ejemplo n.º 1
0
        private bool InvokeDownload(string remoteFile, string destFile, short chunkCount)
        {
            string        downloadUrl = DownloadDir + remoteFile + ".txt";
            WebDownloader downloader  = DownloaderFactory.GetDownloader(new TransferParameter()
            {
                ChunkCount = chunkCount, Environment = _environment, TransferUrl = downloadUrl, LocalFile = destFile, RemoteFile = remoteFile, SupportBrokenResume = _supportBorkenResume, SupportDebug = _supportDebug
            });

            try
            {
                bool hasFinished = false;
                downloader.Completed += new CompletedEventHandler(OnCompleted);
                downloader.Completed +=
                    new CompletedEventHandler(
                        delegate(object sender, CompletedEventArgs args) { hasFinished = true; });
                downloader.ExceptionError +=
                    new ExceptionEventHandle(
                        delegate(object sender, ExceptionEventArgs args) { hasFinished = true; });
                downloader.ExceptionError += new ExceptionEventHandle(OnException);
                downloader.Progress       += new ProgressEventHandle(OnProgress);
                downloader.Start();
                while (!hasFinished)
                {
                    Thread.Sleep(100);
                }
                return(true);
            }
            catch (Exception ex)
            {
                _errmsg = ex.Message;
                throw new ApplicationException(ex.Message);
            }
        }