TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Rahul Shinde
NA
7
0
WebBrowser object in thread....
Dec 9 2014 2:35 AM
I have an console application which uses webbrowser object which navigate and url which has multiple buttons.. The button tooks 3-4min to complete the operation assigned to button. I want if the button operation took more than 4 min then it terminate the process and move to next button.
for this i wrote the following sample code but its not working .. Giving an error "'webBrowser1.Document' threw an exception of type 'System.InvalidCastException'"
public static void googleCall()
{
WebBrowser webBrowser1 = new WebBrowser();
webBrowser1.Navigate("https://www.google.co.in");
webBrowser1.ScriptErrorsSuppressed = true;
bool isReady = false;
Application.DoEvents();
while (webBrowser1.ReadyState != WebBrowserReadyState.Complete)
{
Application.DoEvents();
isReady = false;
}
if (webBrowser1.ReadyState == WebBrowserReadyState.Complete)
{
isReady = true;
}
if (isReady)
{
List<string> x = new List<string>();
x.Add("1");
x.Add("2");
x.Add("3");
foreach (var x1 in x)
{
int qryTimeOut = 200000;
ManualResetEvent wait = new ManualResetEvent(false);
Thread work = new Thread(new ThreadStart(() =>
{
GetResponse(webBrowser1);
wait.Set();
}));
work.SetApartmentState(ApartmentState.STA);
work.Start();
Boolean signal = wait.WaitOne(qryTimeOut);
if (!signal)
{
work.Abort();
}
wait.Dispose();
}
}
}
public static void GetResponse(WebBrowser Browser)
{
}
Error as follows:
Reply
Answers (
0
)
Shadow Detection
Drawing inside PrintDocuments Page Margin is impossible