开发者

vb net invoke inside module

I'm using vb.net in Visual Studio 2008. I've setup a public sub inside of a module that I'm trying to get multiple thre开发者_如何学运维ads to be use to update a rich text box.

I would normally be using ME.INVOKEREQUIRED....,but it's telling me that "ME" is not valid inside of a module.

Could someone please point me in the right direction here?


You need to check the InvokeRequired property of your RichTextBox instance.


That's right. A VB Module is a static class and the Me keyword does not make sense for it. You need an instance of a class to be to use Me. It also has to be derived from Control if you're going to cal InvokeRequired. You probably need to create and open a Form from your module.

Check out this VB article about Accessing Controls from Worker Threads to get started.

By the way, I'm of the opinion that Modules are a horrible idea and should never be used outside of the application's entry point code. Static classes are useful but the Module is not only static but completely global. i.e. all of its members are globally accessible. This situation can get to be very problematic...

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜