Answer the question
In order to leave comments, you need to log in
How to use progress bar?
I made a YouTube video loader, but I can't get the progress bar to work.
progressBar1.Value = 0;
await Task.Run(() =>
{
using (var service = Client.For(YouTube.Default))
{
while (true)
{
var video = service.GetVideo(link_tb.Text);
string path = Path.Combine(save_tb.Text, video.FullName);
File.WriteAllBytes(path, video.GetBytes());
}
}
});
Answer the question
In order to leave comments, you need to log in
// предполагается что ваш сервис скачивает асинхронно, и после скачивания части файла вызывает это событие
service.DownloadChunk += ChunkProcess;
private void ChunkProcess(object sender, int size)
{
// обязательно проверьте в каком потоке обновляете UI
// https://docs.microsoft.com/ru-ru/dotnet/framework/winforms/controls/how-to-make-thread-safe-calls-to-windows-forms-controls?view=netcore-3.1
progressBar1.Value += size;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question