How to prevent the error while updating ui control from another thread?



How to prevent the error while updating ui control from another thread?..

Answer / Sachin Varshney

To update a UI control safely from another thread, you can use Control.Invoke or Control.BeginInvoke:nnExample using Invoke:n```csharpn// Some code running on another thread
this.BeginInvoke((Action)(() => myControl.Text = "New Text"));n```

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Sharp Interview Questions

What is the difference between class and namespace?

1 Answers  


Do while loops yes or no c#?

1 Answers  


What is console writeline in c#?

1 Answers  


What is the difference between serialization and deserialization in c#?

1 Answers  


How long will it take to learn c sharp?

1 Answers  


How big is an int in c#?

1 Answers  


Does c# have its own class library?

1 Answers  


Which control cannot be placed in mdi?

1 Answers  


What are methods c#?

1 Answers  


Suppose you have already existing application with Visual Studio 6 (VB 6, InterDev 6) and this application utilizes Windows 2000 COM+ transaction services. With this example how can you approach migrating this application to .NET?

1 Answers   Siebel,


What?s the implicit name of the parameter that gets passed into the class? set method?

1 Answers  


Why do we need singleton pattern in c#?

1 Answers  


Categories