O.P. Invoking main thread in plugin to call DisplayToast
I'm a C# programmer, not really a VB.net programmer, and I am unable yet to get back to the main thread of my plugin (that I'm coding in VB.net).
Desc: I have my plugin thread in VB.net that is calling some library I wrote in C# which generate an event that my plugin receives on callback. However, since the event is not generated on the main thread, when I call DisplayToast, nothing shows up (which is normal as stated by this line in the function definition of DisplayToast by Patchou) : "Technical Note: the message must be sent from the same thread Initialize() was called, else, Messenger Plus! will reject the call for security reasons."
Question: how can I use delegates in VB.net to get back to my main thread? Normally using C#, I would do something like this to get to my main thread:
public delegate void CompletedMyFunctionDelegate( bool callSuccess );
private void CompletedMyFunction(bool callSuccess)
{
if( this.InvokeRequired )
{
this.Invoke(new CompletedMyFunctionDelegate(CompletedMyFunction), new object[] { callSuccess });
return;
}
// other code here running on main thread
}
any help from VB.net programmers would be appreciated.
thanks.
|