Click here to Skip to main content
14,450,027 members
Rate this:
Please Sign up or sign in to vote.
See more:
Please help how to convert below code using WPF in C#

While pageready = False
If WebBrowser1.ReadyState = WebBrowserReadyState.Complete Then
pageready = True
MessageBox.Show("Ready")
Else
pageready = False
Application.DoEvents()
End If

What I have tried:

While pageready = False
If WebBrowser1.ReadyState = WebBrowserReadyState.Complete Then
pageready = True
MessageBox.Show("Ready")
Else
pageready = False
Application.DoEvents()
End If
Posted
Updated 5 days ago
Rate this:
Please Sign up or sign in to vote.

Solution 1

Transcoding this to C# is trivial; there are only slight differences in syntax.

While I could do this in a manner of minutes, it would be best off for you to use MS Documentation so that you can learn the nuances

References:
while - C# Reference | Microsoft Docs[^]
if-else - C# Reference | Microsoft Docs[^]
   
Rate this:
Please Sign up or sign in to vote.

Solution 2

While (!pageready)
{
if (pageready = (WebBrowser1.ReadyState == WebBrowserReadyState.Complete))
MessageBox.Show("Ready");
Application.DoEvents();
}
   
Comments
Richard Deeming 4 days ago
   
C# is case-sensitive: the keyword is while, not While.

And you've changed the behaviour of the code. The original only called Application.DoEvents in the Else block, which is completely missing from your version.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100