Question

I need to call a C++ library from my C# Win8/WinRT app.

The library is multithreaded and manages threads through calls to the Win32 API (WaitForSingleObject, etc.). I was able to figure out the replacements for all these calls (there is always a ...Ex version available for Apps, e.g. WaitForSingleObjectEx from <synchapi.h> see there if you're looking for it).

But there is one call I cannot figure out how to replace: it is a call to the CreateThread function. There is no equivalent, so it looks like such thread creation has to go through the new APIs now.

But I did not dive into the new threading model on WinRT yet. From your experience, what would be the right way to port this threads creation call? The only constraint is that it is a C++ library that I build as a "C++ Library for WinApp" project.

Summing-up:

In a library I am linking against for my app, threads are created through CreateThread Win32 API call. What do I need to change these calls to so that it works in my App environment?

Était-ce utile?

La solution

You are correct: you won't be able to simply replace CreateThread with a new call. You will have to port your threading code to the new APIs.

From my experience, the link Raman Sharma's posted is a great reference if you wish to port your code more easily to the WinRT ThreadPool model. I have successfully used the shim found there to implement a Win32 thread emulation layer that my older Win32-dependent code can interact with.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top