S
S
Seganapa2012-12-21 08:31:51
Automation
Seganapa, 2012-12-21 08:31:51

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++;
         
            }


Please tell me the correct solution...

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Seganapa, 2012-12-21
@Seganapa

I wonder what the downside is?

E
easyman, 2012-12-21
@easyman

Why not just make 2 post requests with WebClient?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question