Beispiel #1
0
        public void Download(Uri url, string saveLoc)
        {
            try
            {
                using (ExtendedWebClient setupDownloader = new ExtendedWebClient())
                {
                    setupDownloader.DownloadProgressChanged += new DownloadProgressChangedEventHandler(setupDownloader_DownloadProgressChanged);
                    setupDownloader.DownloadFileCompleted += new System.ComponentModel.AsyncCompletedEventHandler(setupDownloader_DownloadFileCompleted);
                    setupDownloader.DownloadFileAsync(url, saveLoc);

                    Console.WriteLine("Downloading setup - ");
                    threadBlocker = new AutoResetEvent(false);
                    threadBlocker.WaitOne();
                }

                if (isSuccessful == false)
                {
                    throw error;
                }
            }
            finally
            {
                if (threadBlocker != null)
                {
                    threadBlocker.Close();
                    threadBlocker = null;
                }
            }
        }