本文整理汇总了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);
}
}
}
示例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);
}
}
}
}