0

How to invoke changes to control from a background thread?

I used the code below for controls using .NET CF 3.5 but how to do it in .NET 2.0?

if (button2.InvokeRequired)
{
    button2.Invoke((Action)(() => button2.Enabled = true));
}
poke
  • 369,085
  • 72
  • 557
  • 602
HellOfACode
  • 1,675
  • 3
  • 18
  • 38
  • See https://learn.microsoft.com/en-us/dotnet/framework/winforms/controls/how-to-make-thread-safe-calls-to-windows-forms-controls – Fildor Sep 05 '17 at 07:33
  • 2
    What is the problem exactly? [`Invoke`](https://msdn.microsoft.com/en-us/library/zyzhdc6b(v=vs.80).aspx) is available in 2.0, [`Action`](https://msdn.microsoft.com/en-us/library/018hxwa8(v=vs.80).aspx) too. Seen [this answer](https://stackoverflow.com/a/253150/1997232) ? – Sinatr Sep 05 '17 at 07:34
  • @Sinatr Yes i pretty much needed to use MethodInvoker and all went well. Thank You – HellOfACode Sep 05 '17 at 07:43

0 Answers0