nice_guy_mel
August 8th, 2007, 02:07 PM
I have an unmanaged class. In old Microsoft Visual Studio 6, this classed used a 3rd party library to implement threads. Now that we are moving our projects into the .Net framework, I wanted to re-write the class to use System::Threading::Thread instead of our 3rd party library. I was hoping it would be as simple as having a
gcroot<Thread^> m_pThread;
member variable, and then use it to start running my Run() method. Now I'm not certain if it is even possible. From what I've read about the Thread constructor, it requires a ThreadStart object. The ThreadStart object constructor requires a handle to a System::Object. This implies that you can only have a Thread launch methods from Managed Classes, and not Unmanaged Classes. Is this indeed the case?
There is a second ThreadStart constructor that takes in a void(*)(void) parameter... could this be something I could use?
gcroot<Thread^> m_pThread;
member variable, and then use it to start running my Run() method. Now I'm not certain if it is even possible. From what I've read about the Thread constructor, it requires a ThreadStart object. The ThreadStart object constructor requires a handle to a System::Object. This implies that you can only have a Thread launch methods from Managed Classes, and not Unmanaged Classes. Is this indeed the case?
There is a second ThreadStart constructor that takes in a void(*)(void) parameter... could this be something I could use?