»Dotnet Ads
»Message Boards
Message Boards
Dotnet Books
»Member Details
Register
Login
LogOut
Submit Code
Submit Jobs
Submit Projects
»Competition
Community
Winners
Prizes
Write For Us
Members
»Other Resources
Links
Dotnet Resources
|
C# Cross thread operation no valid solution when trying to update controls from a thread we come across this error this small code tells how to overcome it
I have a label on a form and i want to update the label from the thread
if we do it inside the thread we get the famous error
the solution
Create a Delegate
public delegate void UpdateHandler(string str);
//// inside the thread call
this.Invoke(new UpdateHandler(changeText), "Hello World" );
//// end inside the thread
private void changeText(string str)
{
label1.text = str;
}
voila you are all set
|