multithreading - VB.NET Invoke Method -
i have method in code:
private sub display() received.appendtext(" - " & rxarray) end sub
whats difference between 2 calls:
me.invoke(new methodinvoker(addressof display))
and
display()
i know threading, i'm not sure.
thanks in advance
use invoke
way when you're working in different threads. example if caller not in same thread gui.
if caller doesn't need wait result of method, use begininvoke
:
guiobject.begininvoke(new methodinvoker(addressof display))
or shorter:
guiobject.begininvoke(sub() display)
for more ease of writing move invoking display
function:
private sub display() if me.invokerequired me.invoke(sub() display) return end if received.appendtext(" - " & rxarray) end sub
that way caller doesn't have know whether in same thread or not.
Comments
Post a Comment