CreateThread for Windows 8 Metro

Originally posted to Shawn Hargreaves Blog on MSDN, Monday, March 12, 2012

The WinRT programming environment, which is used to create Metro applications for Windows 8, replaces the old Win32 threading APIs such as CreateThread with a new ThreadPool::RunAsync API.  This is generally a good thing (ThreadPool is better than CreateThread for several reasons) but it can be a pain when trying to port existing code that depends on those older APIs.

Porting shim to the rescue!  This code emulates a subset of the Win32 threading APIs as a wrapper on top of WinRT ThreadPool:

Get it here:  ThreadEmulation.zip

I recommend only using this for porting legacy code.  When writing new Metro applications, it is better to directly use WinRT ThreadPool.

Blog index   -   Back to my homepage