Windows窗体应用程序中的进度栏 异常
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Windows窗体应用程序中的进度栏 异常相关的知识,希望对你有一定的参考价值。
我正在尝试更新我的Windows窗体应用程序的进度条,这基本上是一个下载YouTube视频的应用程序。但是我在进度条方法上得到一个名为'System.ArgumentOutOfRangeException'的异常。请帮我解决这个问题。谢谢! :)
private void button1_Click(object sender, EventArgs e)
{
progressBarOverall.Minimum = 0;
progressBarOverall.Minimum = 100;
IEnumerable<VideoInfo> videos = DownloadUrlResolver.GetDownloadUrls(textBox1.Text);
VideoInfo video = videos.First(p => p.VideoType == VideoType.Mp4 && p.Resolution == Convert.ToInt32(cboResolution.Text));//converts video quality
if(video.RequiresDecryption) //Checks if video requiures decryption before downloading the URL
DownloadUrlResolver.DecryptDownloadUrl(video);//
VideoDownloader downloader = new VideoDownloader(video, Path.Combine(Application.StartupPath + "//", video.Title + video.VideoExtension));
downloader.DownloadProgressChanged += Downloader_DownloadProgressChanged;
Thread thread = new Thread(() => { downloader.Execute(); }) { IsBackground = true };
thread.Start();
}
private void Downloader_DownloadProgressChanged(object sender, ProgressEventArgs e)
{
Invoke(new MethodInvoker(delegate ()
{
progressBarOverall.Value = (int)e.ProgressPercentage;
percentagelabel.Text = $"{string.Format("{0:0.##}", e.ProgressPercentage)}%";
progressBarOverall.Update();
}));
}
答案
progressBarOverall.Minimum = 0;
progressBarOverall.Minimum = 100;
你的意思是第二个的最大值?
progressBarOverall.Minimum = 0;
progressBarOverall.Maximum= 100;
以上是关于Windows窗体应用程序中的进度栏 异常的主要内容,如果未能解决你的问题,请参考以下文章