The Old New Thing

Practical development throughout the evolution of Windows.

Latest posts

The case of COM failing to pump messages in a single-threaded COM apartment
Mar 14, 2025
0
2

The case of COM failing to pump messages in a single-threaded COM apartment

Raymond Chen
Raymond Chen

A customer encountered a hang caused by COM not pumping messages while waiting for a cross-thread operation to complete. They were using the class for serializing asynchronous operations on a UI thread they created to handle accessibility callbacks. The hang stack looked like this: We see that we have a UI thread (notice the at the bottom of the stack), yet COM decided to block without pumping messages ( instead of (). Is this a bug in the task sequencer? Let's look at the stack more closely. A message arrived via , and that then queued a task into the task sequencer. The saw that the task sequencer had...

Making sure that a DLL loads only from your application directory
Mar 13, 2025
3
1

Making sure that a DLL loads only from your application directory

Raymond Chen
Raymond Chen

You can ask for it as an option, but think about what you're actually protecting against.

What are the thread safety requirements of <CODE>HSTRING</CODE> and <CODE>BSTR</CODE>?
Mar 12, 2025
2
2

What are the thread safety requirements of HSTRING and BSTR?

Raymond Chen
Raymond Chen

They do not have thread affinity.

What an insightful observation, you get to wear “the hat”
Mar 11, 2025
7
2

What an insightful observation, you get to wear “the hat”

Raymond Chen
Raymond Chen

Maybe not so insightful.

How do I destroy an ABI pointer that I extracted from a C++/WinRT object?
Mar 10, 2025
0
3

How do I destroy an ABI pointer that I extracted from a C++/WinRT object?

Raymond Chen
Raymond Chen

You can clean it up the ABI way, whatever that is.

To some people, time zones are just a fancy way of sounding important, episode 2
How can I choose a different C++ constructor at runtime?
Mar 6, 2025
6
5

How can I choose a different C++ constructor at runtime?

Raymond Chen
Raymond Chen

Make somebody else do it, and then use copy elision.

I tried to subscribe to a C++/WinRT event, but my callback was never called
Mar 5, 2025
0
2

I tried to subscribe to a C++/WinRT event, but my callback was never called

Raymond Chen
Raymond Chen

Check how you registered your event handler.

Microspeak: Respin
Mar 4, 2025
2
2

Microspeak: Respin

Raymond Chen
Raymond Chen

Spin it up again, baby.