當前位置: 首頁>>代碼示例>>C#>>正文


C# ProgressBar.Dispose方法代碼示例

本文整理匯總了C#中System.Windows.Forms.ProgressBar.Dispose方法的典型用法代碼示例。如果您正苦於以下問題:C# ProgressBar.Dispose方法的具體用法?C# ProgressBar.Dispose怎麽用?C# ProgressBar.Dispose使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Windows.Forms.ProgressBar的用法示例。


在下文中一共展示了ProgressBar.Dispose方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1:

        private void cancelbutton_click
            (object sender, EventArgs e, WebClient client,PictureBox cancelbutton,
            ProgressBar progressbar,string filename,TextBox episode = null)
        {
            const string message = "確定取消下載麽?";
            const string caption = "取消下載";
            if (cancelbutton.Name.StartsWith("batch"))
            {
                client.CancelAsync();
                client.Dispose(); //without it, deleting file would fail.
                batchpanel.Controls.Remove(episode);
                batchpanel.Controls.Remove(cancelbutton);
                batchpanel.Controls.Remove(progressbar);
                cancelbutton.Dispose();
                progressbar.Dispose();
                episode.Dispose();
                File.Delete(filename);
            }
            else 
            {
                var result = System.Windows.Forms.MessageBox.Show(message, caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (result == DialogResult.Yes)
                {
                    client.CancelAsync();
                    client.Dispose();
                    infopanel.Controls.Remove(cancelbutton);
                    infopanel.Controls.Remove(progressbar);
                    cancelbutton.Dispose();
                    progressbar.Dispose();
                    File.Delete(filename);
                }
            }

        }
開發者ID:polyval,項目名稱:ESLPodcast,代碼行數:34,代碼來源:MainForm.cs

示例2: downloadDriver


//.........這裏部分代碼省略.........
                // isolate saveFileDialog errors with accually downloading GPU driver

                // @todo add status bar for download progress
                // @todo do the saveFileDialog in a loop

                bool error = false;
                try
                {
                    string driverName = downloadURL.Split('/').Last(); // retrives file name from url

                    DialogResult result;

                    using (SaveFileDialog saveFileDialog = new SaveFileDialog()) {
                        saveFileDialog.Filter = "Executable|*.exe";
                        saveFileDialog.Title = "Choose save file for GPU driver";
                        saveFileDialog.FileName = driverName;

                        result = saveFileDialog.ShowDialog(); // show dialog and get status (will wait for input)

                        switch (result)
                        {
                            case DialogResult.OK:
                                savePath = saveFileDialog.FileName.ToString();
                                break;

                            default:
                                // savePath = Path.GetTempPath() + driverName;

                                // if something went wrong, fall back to downloads folder
                                savePath = getDownloadFolderPath() + driverName;
                                break;
                        }
                    }

                    if (debug == true) {
                        Console.WriteLine("savePath: " + savePath);
                        Console.WriteLine("result: " + result);
                    }

                    Console.Write("Downloading the driver . . . ");

                    using (WebClient webClient = new WebClient())
                    {
                        var notifier = new AutoResetEvent(false);
                        var progress = new ProgressBar();

                        webClient.DownloadProgressChanged += delegate (object sender, DownloadProgressChangedEventArgs e)
                        {
                            progress.Report((double)e.ProgressPercentage / 100);

                            if (e.BytesReceived >= e.TotalBytesToReceive) notifier.Set();
                        };

                        webClient.DownloadFileAsync(new Uri(downloadURL), savePath);

                        notifier.WaitOne(); // sync with the above
                        progress.Dispose(); // get rid of the progress bar
                    }

                }
                catch (Exception ex)
                {
                    error = true;
                    Console.Write("ERROR!");
                    LogManager.log(ex.Message, LogManager.Level.ERROR);
                    Console.WriteLine();
                    Console.WriteLine(ex.StackTrace);
                    Console.WriteLine();
                }

                if (error == false)
                {
                    Console.Write("OK!");
                    Console.WriteLine();
                }

                Console.WriteLine();
                Console.WriteLine("The downloaded file has been saved at: " + savePath);

                dialog = MessageBox.Show("Do you want view the release PDF?", "TinyNvidiaUpdateChecker", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (dialog == DialogResult.Yes) {
                    try {
                        Process.Start(pdfURL);
                    }
                    catch (Exception ex) {
                        Console.WriteLine(ex.StackTrace);
                    }
                }

                dialog = MessageBox.Show("Do you wish to run the driver installer?", "TinyNvidiaUpdateChecker", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (dialog == DialogResult.Yes) {
                    try {
                        Process.Start(savePath);
                    } catch (Exception ex) {
                        Console.WriteLine(ex.StackTrace);
                    }

                }
            }
        }
開發者ID:ElPumpo,項目名稱:TinyNvidiaUpdateChecker,代碼行數:101,代碼來源:MainConsole.cs


注:本文中的System.Windows.Forms.ProgressBar.Dispose方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。