I'm trying to create my own web browser for my practice on windows application. So I've make a windows fo开发者_StackOverflowrm for web browser. Now I want to use backgroundworker
or progressbar
to show real process of page loading but I don't know how to do it. I tried with Google but no result for me. So please help me if my question is right to ask about it.
// add progress bar
private ProgressBar progressBar1;
//create event for ProgressChanged
Browser.ProgressChanged += Browser_ProgressChanged;
...
// set progress bar value when ProgressChanged event firing
void Browser_ProgressChanged(object sender, WebBrowserProgressChangedEventArgs e) {
if (e.MaximumProgress > 0) {
int prog = (int)(100 * e.CurrentProgress / e.MaximumProgress);
progressBar1.Value = prog;
}
}
- C# Winforms: Using a progress bar with Web Browser Control
Here are some links:
http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.aspx
http://www.dotnetperls.com/backgroundworker
http://www.codeproject.com/KB/cs/bgworkercomponent.aspx
精彩评论