A neat way to call InvokeRequired and Invoke

I seem to remember how I noticed a way to invoke InvokeRequired and Invoke neatly to avoid repeating too much code in each event handler, but I can't remember what it was. So does anyone know a neat way to write this code?

Preferred for VB.Net 2005.

+3
source share
2 answers

The SO question here addresses this issue from a C # point of view, and any of the answers can probably be easily adapted to VB.

Although my answer was not accepted, I believe that using the anonymous method method MethodInvokeris the easiest.

, .

+1

- , Roy Osherove ( , DLL):

[RunInUIThread]
protected virtual void DoSomeUIStuff()
{
  this.Text = "hey";
}
+1

Source: https://habr.com/ru/post/1743511/


All Articles