Answer the question
In order to leave comments, you need to log in
Webbrowser C# How to pause
I am writing a small application using webbrowser.
There is a form, I fill it programmatically, I press the button,
the Form changes without reloading the page (Ajax), i.e. can't track the update.
You also need to enter some data into the second form ... I
see two solutions - either somehow catch the page refresh event, or pause the execution ...
But I couldn’t find how to implement it correctly ...
I found such a function, it works, but very slowly …
private void waitTillLoad()
{
WebBrowserReadyState loadStatus;
//wait till beginning of loading next page
int waittime = 100000;
int counter = 0;
while (true)
{
loadStatus = webBrowser1.ReadyState;
Application.DoEvents();
if ((counter > waittime)||(loadStatus == WebBrowserReadyState.Uninitialized)||(loadStatus == WebBrowserReadyState.Loading)||(loadStatus == WebBrowserReadyState.Interactive))
{
break;
}
counter++;
}
//wait till the page get loaded.
counter = 0;
while (true)
{
loadStatus = webBrowser1.ReadyState;
Application.DoEvents();
if (loadStatus == WebBrowserReadyState.Complete)
{
break;
}
counter++;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question