I'd like to use await Task.Run(DoWork)
, to do some repetitive single-threaded computational work on ThreadPool. The problem is, I need to use STA COM objects inside DoWork
, so I guess I cannot use ThreadPool because I cannot alter the apartment state of a pool thread.
How can I still use async
/await
in this scenario? Creating my own pool of STA threads with a custom task scheduler sounds like an excessive work.