I\'ve been using the Concurrency Runtime in a C++ static library, and recently wanted to use this library in a C++/CLI project, to take advantage of the Windows Form designe
Using ConcRT in C++/CLI is explicitly disabled in concrt.h via the statement below because it is not officially supported...
#if defined(_M_CEE)
#error ERROR: Concurrency Runtime is not supported when compiling /clr.
#endif
You can use PInvoke to work around this as suggested above, or you can also use the pointer to implementation idiom to address this by forward declaring a 'pimpl' class and hide the dependency on concrt.h to a native .cpp file which you can then compile into a lib and link against with the header file.
e.g. in the .h file:
//forward declaration
class PImpl;
class MyClass
{
....
//forward declaration is sufficient because this is a pointer
PImpl* m_pImpl;
}
e.g. in your .cpp file which compiles into a native lib:
#include
class PImpl
{
//some concrt class
Concurrency::task_group m_tasks;
}