private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
//list of tasks
}
private void webBrowser2_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
//list of tasks
}
see above. my question is, how to make both of them to run at the same time(make two threads to manually control the monitoring of them), now the problem is they all runs separately on the main thread, and i can'd do other tasks, thanks for the helps! sorry about the bad english
and i have tried to use, for example:
Thread threadw1 = new Thread(() => webBrowser1.Navigate("url1"));
Thread threadw2 = new Thread(() => webBrowser2.Navigate("url2"));
threadw1.Start();
threadw2.Start();
but that is to use threads to navigate, once the navigation is done, then the system runs the document completed separately. and i dont know how to control them, thanks for the help!
i have wrapped the tasks in a function and now the problem is when i do this, it doesn't work
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
if (webBrowser1.ReadyState < WebBrowserReadyState.Complete) return;
// Do the work, you have the event args in ev
Thread wbb1 = new Thread(() => wb1task());
wbb1.Start();
//wb1task();
}
but when i do this it works, but it becomes a single thread again:
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
if (webBrowser1.ReadyState < WebBrowserReadyState.Complete) return;
// Do the work, you have the event args in ev
//Thread wbb1 = new Thread(() => wb1task());
// wbb1.Start();
wb1task();
}
the thread started then the document completed, i need something to hold after wbb1.Start(); to prevent it to go out of the loop:)
ok this solves the problem, thanks everyone!
wbb1.SetApartmentState(ApartmentState.STA);