开发者

Neat way of calling InvokeRequired and Invoke

I seem to remember seeing some neat way of calling InvokeRequired and Invoke to avoid repeating too much code in every event handler but I can't 开发者_运维问答remember what that was.

So does anyone know a neat way of writing that code?

Preferably for VB.Net 2005.


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

Although my answer wasn't the accepted one, I find using MethodInvoker anonymous method approach to be the most straightforward.

Hope this helps.


One way to streamline it is to use the method described in Roy Osherove's Blog (keep in mind it requires using a custom DLL):

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜