Shoutbox

Invoking main thread in plugin to call DisplayToast - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Forum: Plug-Ins (/forumdisplay.php?fid=28)
+------ Thread: Invoking main thread in plugin to call DisplayToast (/showthread.php?tid=47293)

Invoking main thread in plugin to call DisplayToast by ketchup_blade on 07-07-2005 at 01:26 PM

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.


RE: Invoking main thread in plugin to call DisplayToast by RaceProUK on 07-07-2005 at 08:29 PM

Does VB.NET not have this 'delegates' feature? Given the .NET runtime and the Common Language schnazz, it should be possible to mix-and-match VB.NET and C# - it's just a case of getting the right keywords.