Article

Why didn’t we use the COM static store to clean up the unmarshalable delegate?

Luca Bacci ·The Old New Thing ·Published 2026-10-23 ·5 min read

This article discusses the limitations of using the COM static store for managing unmarshalable delegates, particularly in the context of single-threaded apartments in UWP applications.

From the article

A third suggestion from Luca Bacci on creating a fake agile wrapper that is technically agile but is not useful outside its home apartment was to use the COM static store .

The COM static store doesn’t help us, because the COM static store runs down when the last thread shuts down COM, whereas we want something that runs down when a single apartment shuts down COM.

There is a per-apartment version of the COM static store, but it is part of the Core­Application­View , which is (1) something that only UWP programs have, and (2) exists only for apartments that have a core application view, and those are restricted to single-threaded apartments.


Share this resource


Discovered 2026-10-26 Source The Old New Thing Archive 2026-10 →