示例#1
0
        private void btnDownload_Click(object sender, EventArgs e)
        {
            Uri uri = new Uri("https://github.com/rogerclarkmelbourne/OpenGD77/releases");

            wc = new WebClientAsync(40);
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;

            this.progressBar.Value = 0;

            wc.DownloadProgressChanged += new DownloadProgressChangedEventHandler(downloadProgressChangedCallback);
            wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(downloadStringCompletedCallback);
            wc.DownloadFileCompleted   += new AsyncCompletedEventHandler(downloadFileCompletedCallback);

            this.progressBar.Visible = true;
            enableUI(false);

            // Retrieve release webpage
            try
            {
                Application.DoEvents();
                wc.DownloadStringAsync(uri);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                enableUI(true);
                this.progressBar.Visible = false;
                return;
            }
        }