Author Topic: .NET OS Threading w/ Plugin Wizard?  (Read 1977 times)

0 Members and 1 Guest are viewing this topic.

Offline RegeG

  • Active Member
  • Posts: 6
    • View Profile
.NET OS Threading w/ Plugin Wizard?
« on: May 26, 2013, 07:04:52 PM »
I'm just starting my first plugin for Mach3.

I'm using the Plugin Wizard with Studio 2008.  I'm able to build and run a plugin, but when trying to start a thread - it doesn't seem to start.  (Currently the thread just tries to open a serial port and dump data.)

I have an object that contains the serial port access code and another that starts a new thread and calls the serial port access code.  I can create the object and call the method to just open the port and spew data and that works.  If I try to create a thread with that then calls the serial port access code nothing happens.

The worker method is:

   public ref class ThcInterface
   {
   public:
      static void DoWork() { SpewData() };
                static void SpewData() { <code> };

        };

I start it with:
       Thread^ comThread = gcnew Thread( gcnew ThreadStart(&ThcInterface::DoWork) );
and I don't get any data.

Calling "SpewData" directly will give serial data.

Is it possible to use .NET threading with the Plugin wizard?  I'm wondering if this is a mixed mode issue.  Any guidance threading with Mach3?


Thanks.


Offline RegeG

  • Active Member
  • Posts: 6
    • View Profile
Re: .NET OS Threading w/ Plugin Wizard?
« Reply #1 on: May 26, 2013, 10:34:30 PM »
It seems like you always find the answer yourself after posting a question.

Thinking it might be an issue with static classes (which I think are truly evil) - I went to just using Win32 to start the thread:
   MG::hndlSerialThread = CreateThread(NULL, 0, SerialProcessing, NULL, 0, 0);

That worked fine.