C# BackgroundWorker and ProgressBar with Cancellation
ฝัง
- เผยแพร่เมื่อ 21 ก.ย. 2024
- C# BackgroundWorker Tutorial and Example with ProgressBar.
SOURCE CODE REFERENCE : camposha.info/s...
Backgroundworker;Progress bar;Cancelling;Threads;
What is one functionality that I cannot do without when making a fairly complex application,its Threads.Yet background worker provides us with a simple class called background worker that abstracts away the difficulty leaving it fairly simple.
We've written this tutorial with a step by step approach and clear comments.....Enjoy.
We've covered :
BackgroundWorker DoWork;
,ProgressChanged;
Completed;CancelAsync; etc
This is the only one complete tutorial I have found on Backgroundworker issue. Thank you so much!
You are welcome.
This is really a great help to me, since its my first time to use the background worker. Thank you very much for this video toturial.
+Michael Gecozo Cheers!!
Really helpful. Thanks for making these videos. One thing abt the video. even after cancelling, the whole work completed. so use a return or break statement to stop the work. sorry for bad english
Thanks for the comment and suggestion.I shall have a look at it.
Really nice video, everything described step by step, great work and Thank you.
Bark Ups Thanx too.
your explanation is clear and neat, thank u so much i feel gud because it is easy to understand
shobia therasa Nice to hear that,thanks.
I'm now deaf because my audio had to be turned to max, and after the video it blew out and eardrum
This was really helpful, thank you for explaining things so it was easy to understand what each item is doing and why it is needed. Question: how did you add the Background Worker from the toolbar? I don't see that option in mine. Thanks!
Jean Hunt Hello James,thanks first for watching this video and commenting.Which version of Visual Studio are you using?? You should find Background Worker component by just searching in your search box on top of the toolbar.
Right click the toolbox and click add from menu. And from the popup dialog select the backgroundworkerprocess from the list of available controls.
Press ok this will add the backgroundworkerprocess to ypur toolbox.
Thanks for the video, explains a lot regarding Background Worker :)
You are welcome.
Very useful and very clear. Thanks.
Premkumar Elangovan You are welcome,Premkumar.
Great Video. Thank you for sharing. What I'm curious now is that how would you implement jobs to run in the background. Say I have 10 batch files that installs applications? How can you implement so that it waits for the first batch file to finish and update the progress bar?
SOURCE CODE REFERENCE : camposha.info/source/c-backgroundworker-update-progressbar-cancellation/
thank you so much, you solved for me CancellationPending
You are welcome,
is there a way how to make a pause button using backgroundworker?
Hi. Great video.I´m having a little problem with RunWorkerCompleted event.It is not invoked after DoWork is completed.Can you help?Thanks.
Thanks ,it is good explained.
You are welcome.
Good video.. Please try to keep recording volume high, next time.
SavindraSingh Shahoo Thanks for the comment,videos for 2015 onwards are much better in terms of sound quality.
good job mate..
You are welcome.
hi nice tutorial, but how about loading a form after the progress bar is at 100%? how will I do that? Please help me..
jiyekh canatuan Hi Jiyekh thanks for commenting,am not getting you well.What do you mean by after progressbar is 100% ?? Here the we are using a loop that counts upto 100.If you have a value greater than 100 then you can still set it as the maximum for ProgressBar.
This is what is in the tutorial :
//Maximum value for progressbar
progressBar1.Maximum=100;
//Then we looped upto 100 for simplicity
for(int i=0; i
i mean i need to load a form (which takes too much time to load for about 20-30secs) after the progress bar is at 100%.
Your example in your video, after the progress bar reached 100%, you display a message "successful". in my case i want to load a form.
Thanks man!
+Aleksandar Jovanovic Cheers.
When the progressbar is already 100% can i make it show a message ? please reply asap
Yes! Put your MessageBox at Event ProgressChanged (after line ProgressBar)
Example:
private void bw_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
this.tbProgress.Text = (e.ProgressPercentage.ToString() + "%");
MessageBox.Show("Done!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
can you speak a bit more loud?
Hi all,what about a Circular Progressbar and Timer here: th-cam.com/video/xBfiYXBeFBk/w-d-xo.html
cant hear youuuuuu...?
Sorry bro.
Your Audio Was out of Sync :P
Sorry.Thanks for the feedback.
Are you ugandan?
Hey nope your neighbour Kenyan.
Man if you want to present something, presenting like it should be. If it is not Ok the first time you will record it second and third. It is useless to offer something to people which they cannot hear. Record it again.
Alright great feedback.This was 2014 and av grown since then. However, I appreciate your feedback and I will take it into account.
I am glad you perceive it as constructive rather than offensive :) Keep goin' :) And always make things better :)
Great.
Just do a dubbing on this old video with loud audio again.
bad tutorial, fix your sound
Good feedback I agree.