Updating UI from another thread in windows application
While deigning windows application we sometimes require to spawn thread to do a long running operation like IO. During this course if want to update controls on UI thread for indication or messages like success or failure in case of exception.
If we directly try to update Control on UI from different thread we get exception. In order to achieve same following code snippet can be used:
Invoke(new MethodInvoker(delegate()
{
//Change any control property.
}));
OR
Invoke(new MethodInvoker(Method name changing UI properties.));
Hope this helps.
If we directly try to update Control on UI from different thread we get exception. In order to achieve same following code snippet can be used:
Invoke(new MethodInvoker(delegate()
{
//Change any control property.
}));
OR
Invoke(new MethodInvoker(Method name changing UI properties.));
Hope this helps.
Comments
Post a Comment