Hello. I try to use this code :
webBrowser.Document.GetElementById("login").SetAttribute("value", "user");
It work great but not when i use it in a new thread. I get an InvalidCastException. What can I do ?
Hello. I try to use this code :
webBrowser.Document.GetElementById("login").SetAttribute("value", "user");
It work great but not when i use it in a new thread. I get an InvalidCastException. What can I do ?
webBrowser
must be a GUI element, and most GUI elements do not handle multi-threading well. You should typically only access GUI objects on the main UI thread of the application.
The easiest way to delegate calls to the UI thread is to use Dispatcher.Invoke.