Help - unmanaged threads and IJW DLL
-
Help! I have this problem. I am linking to an unmanaged DLL using IJW (just including the headers). This DLL is thread-safe and calls must run in a thread. I have used the System::Threading classes to create a thread. However, the thread class I have must be integrated into an unmanaged class that inherits from a base class in the dll: e.g. class A : public QQLListener {} where QQLListener is a class in the unmanaged DLL library. However, the thread must be in class A, but you cannot use System::Threading in an unmanaged class and the class CANNOT be managed because it must inherit from an unmanaged abstract base class. What is a solution? Is there a non .NET framework Threading library? My application cannot use MFC, it must be console mode. I need a threading system that works in unmanaged code in console mode in a .NET managed C++ project. Any ideas? Thanks
-
Help! I have this problem. I am linking to an unmanaged DLL using IJW (just including the headers). This DLL is thread-safe and calls must run in a thread. I have used the System::Threading classes to create a thread. However, the thread class I have must be integrated into an unmanaged class that inherits from a base class in the dll: e.g. class A : public QQLListener {} where QQLListener is a class in the unmanaged DLL library. However, the thread must be in class A, but you cannot use System::Threading in an unmanaged class and the class CANNOT be managed because it must inherit from an unmanaged abstract base class. What is a solution? Is there a non .NET framework Threading library? My application cannot use MFC, it must be console mode. I need a threading system that works in unmanaged code in console mode in a .NET managed C++ project. Any ideas? Thanks
You cannot derive managed class from an unmanaged class. You should do something like this __gc class A { QQLListener* pSl; public: A() { pSl = new QQLListener(); } void ThreadStart() { pSl->threadStart(); } }
-
Help! I have this problem. I am linking to an unmanaged DLL using IJW (just including the headers). This DLL is thread-safe and calls must run in a thread. I have used the System::Threading classes to create a thread. However, the thread class I have must be integrated into an unmanaged class that inherits from a base class in the dll: e.g. class A : public QQLListener {} where QQLListener is a class in the unmanaged DLL library. However, the thread must be in class A, but you cannot use System::Threading in an unmanaged class and the class CANNOT be managed because it must inherit from an unmanaged abstract base class. What is a solution? Is there a non .NET framework Threading library? My application cannot use MFC, it must be console mode. I need a threading system that works in unmanaged code in console mode in a .NET managed C++ project. Any ideas? Thanks
Anonymous wrote: Is there a non .NET framework Threading library? My application cannot use MFC You can use the API.
CreateThread()
. Or CRT._beginthreadex()
Nish
Regards, Nish Native CPian. Born and brought up on CP. With the CP blood in him.
-
Thanks for the advice, but unfortunately this will not work either. QQLListener is the base class of a subject-observer design pattern, it must be inherited by a derived class so that the callback methods inside it are called. I suppose there is no way to use my old C++ library with the .net framework. I think it's not quite as "compatible" as they claim.
Anonymous wrote: . I think it's not quite as "compatible" as they claim. The stuff is compatible the exact way of doing things depends on a case to case basis. If you provide little more details then probably I could help.
-
You cannot derive managed class from an unmanaged class. You should do something like this __gc class A { QQLListener* pSl; public: A() { pSl = new QQLListener(); } void ThreadStart() { pSl->threadStart(); } }
Thanks for the advice, but unfortunately this will not work either. QQLListener is the base class of a subject-observer design pattern, it must be inherited by a derived class so that the callback methods inside it are called. I suppose there is no way to use my old C++ library with the .net framework. I think it's not quite as "compatible" as they claim.