visual studio - How can I mix the Concurrency Runtime with .NET code? -


i've been using concurrency runtime in c++ static library, , wanted use library in c++/cli project, take advantage of windows form designer , avoid mfc. unfortunately, concurrency runtime not compatible /clr switch required in c++/cli. tried surrounding included header files use concurrency runtime in "#pragma unmanaged ... #pragma managed" directives, while that's worked me other code in past, doesn't seem work in case. mean error:

c:\program files (x86)\microsoft visual studio 10.0\vc\include\concrt.h(27): fatal error c1189: #error :  error: concurrency runtime not supported when compiling /clr. 

i'm not super versed in mixing managed , unmanaged code, it's possible there's work-around i'm not aware of. on other hand, perhaps silly approach. if weren't fact find mfc impossibly complex, , form designer nice , easy, i'd pure c++. preference mixing two, suggestions?

using concrt in c++/cli explicitly disabled in concrt.h via statement below because not officially supported...

#if defined(_m_cee)    #error error: concurrency runtime not supported when compiling /clr. #endif 

you can use pinvoke work around suggested above, or can use pointer implementation idiom address forward declaring 'pimpl' class , hide dependency on concrt.h native .cpp file can compile lib , link against header file.

e.g. in .h file:

//forward declaration class pimpl;  class myclass {   ....   //forward declaration sufficient because pointer   pimpl* m_pimpl; } 

e.g. in .cpp file compiles native lib:

  #include <ppl.h>   class pimpl   {    //some concrt class    concurrency::task_group m_tasks;   } 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -