Hello @Shyam Butani ,
how does this work under the hood? Is COM initialized for all threads involved, or is there some other mechanism in place that makes this safe?
winrt::hstring doesn't really have anything to do with COM. It does not require a COM apartment at all. Internally, it is implemented in terms of HeapAlloc / HeapFree and nothing more.
can I safely destroy the string on Thread 2?
And so yes you can create it on one thread and destroy it on another. More generally, it an be transferred across thread boundaries and it is safe to share references between threads.
Thank you.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.