INTERACT FORUM

Windows => Plug-in Development => Topic started by: skeeterfood on September 25, 2009, 10:57:12 pm

Title: Multi-threaded plug-in?
Post by: skeeterfood on September 25, 2009, 10:57:12 pm
Hi guys,

Is it possible to run multiple threads within a plug-in?  If so, anyone got any example code?  I want to run a serial receiver on a separate thread to receive events from my whole-house audio system.  Hooking to MC's events and sending serial commands to the controller seems simple enough, but I'm pretty inexperienced when it comes to threading in C#.

-John
Title: Re: Multi-threaded plug-in?
Post by: muchadhesion on September 26, 2009, 11:19:36 pm
Yes, it is possible to run multiple threads in a plug-in.

I run a HTTP server thread, and a heavily threaded UPnP client stack inside a MC Interface plug-in.  All the usual C# threading techniques work fine.

Something to watch out for:  Many of the MC SDK APIs assume that they are to be executed in the main Windows Control thread, so you'll need to call them via Control.Invoke