microsoft / cppwinrt

C++/WinRT
MIT License
1.67k stars 239 forks source link

STA MTA #111

Closed bigdimboom closed 7 years ago

bigdimboom commented 7 years ago

How do I use a coroutine and specify its threading model STA or MTA?

kennykerr commented 7 years ago

C++/WinRT captures the apartment context before suspending and will resume in the same apartment context. You can also manually switch contexts within a coroutine as illustrated here.

We explained this in detail in our coroutine talk at CppCon last year.

The thread or apartment that a coroutine begins execution on depends on the coroutine type (return type). Most coroutine types don't switch contexts until the first suspension point.