15,905,874 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by omid.r.a.candy (Top 4 by date)
omid.r.a.candy
22-Sep-13 0:23am
View
Hey you,
It's very simple. Consider the following codes:
VB:
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
CheckForIllegalCrossThreadCalls = False
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Number_of_page As Integer
For Number_of_page = 1 To 5
WebBrowser1.ScriptErrorsSuppressed = True
WebBrowser1.Navigate("http://www.codeproject.com/script/Answers/List.aspx?tab=active&alltags=True&tags=842&pgnum=" & Number_of_page)
While WebBrowser1.ReadyState <> WebBrowserReadyState.Complete
Application.DoEvents()
End While
Label1.Text = "Page Number " & Number_of_page & " loaded!"
Next Number_of_page
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim Thread1 As System.Threading.Thread
Thread1 = New System.Threading.Thread(AddressOf Ros)
Thread1.IsBackground = True
Thread1.Start()
End Sub
Private Sub Ros()
For Number_of_page = 1 To 5
WebBrowser1.ScriptErrorsSuppressed = True
WebBrowser1.Navigate("http://www.codeproject.com/script/Answers/List.aspx?tab=active&alltags=True&tags=842&pgnum=" & Number_of_page)
'We must put some code to fix it!!!
'When message must be shown that WebBrowser1 was fully loaded.
Label1.Text = "Page Number " & Number_of_page & " loaded!"
Next Number_of_page
End Sub
End Class
C#:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Button1_Click(object sender, EventArgs e)
{
int Number_of_page;
for (Number_of_page = 1; Number_of_page <= 5; Number_of_page++)
{
WebBrowser1.ScriptErrorsSuppressed = true;
WebBrowser1.Navigate("http://www.codeproject.com/script/Answers/List.aspx?tab=active&alltags=True&tags=842&pgnum=" + Number_of_page);
while (WebBrowser1.ReadyState != WebBrowserReadyState.Complete)
{
Application.DoEvents();
}
Label1.Text = "Page Number " + Number_of_page + " loaded!";
}
}
private void Form1_Load(object sender, EventArgs e)
{
CheckForIllegalCrossThreadCalls = false;
}
private void Button2_Click(object sender, EventArgs e)
{
System.Threading.Thread Thread1;
Thread1 = new System.Threading.Thread(Ros);
Thread1.IsBackground = true;
Thread1.Start();
}
private void Ros()
{
int Number_of_page;
for (Number_of_page = 1; Number_of_page <= 5; Number_of_page++)
{
WebBrowser1.ScriptErrorsSuppressed = true;
WebBrowser1.Navigate("http://www.codeproject.com/script/Answers/List.aspx?tab=active&alltags=True&tags=842&pgnum=" + Number_of_page);
//We must put some code to fix it!!!
//When message must be shown that WebBrowser1 was fully loaded.
Label1.Text = "Page Number " + Number_of_page + " loaded!";
}
}
}
}
omid.r.a.candy
21-Sep-13 20:02pm
View
well Mr.Zemek using Sleep(~) not a good idea! because we don't know how much time needed to page done.i mean using sleep not Engineering way to solve this Problem.
I run up code without Tread and it work very well but my Win.form program Glaciated! or Hanged.So i Decided use thread.
please tell me more about WebControl.Invoke(TheMethodThatDoesTheStatusValidation) and give some code for vb.net or C# to test it.
And i am So glad to Help me.
omid.r.a.candy
21-Sep-13 18:29pm
View
Thank you so much.My friend i know what you told me about:
1-Application.DoEvents ; well i know that we have to Different thread ,but i wanted to told you what i want.i mean is the thread wait for WebBrowser as long as WebBrowser Completed.
2-event; well we have some event for.but don't want to use it.
omid.r.a.candy
18-Sep-13 11:32am
View
Any Comment?