How can I get my shell thumbnail extractors to run in the same process?

Wait 5 sec.

We learned that Explorer uses the COM Surrogate as a sacrificial process when hosting thumbnail extraction plug-ins.A customer had a thumbnail extraction plug-in for which preparing to perform the thumbnail extraction was expensive. But the way Explorer uses thumbnail extractors is that it loads an extractor, asks it to extract a thumbnail from a file, and then frees the extractor. There's no real chance for one extractor to hand off cached state to the next extractor, so the second extractor has to start from scratch.Is there a way to tell Explorer to load all the extractors into the same process and then tell each one, "Okay, transfer your state to the next guy," and tell the last guy, "I'm done extracting, you can clean up now"?No, there is no way to give Explorer precise instructions on how it should use thumbnail extractors, but that doesn't mean you can't build it yourself.What you can do is create two COM objects. One is an in-process object that is the actual plug-in. The other is a multi-use out-of-process local server that does the work. The in-process plug-in forwards the thumbnail extraction requests to the local server. Since the local server is multi-use, all the plug-ins share a single server. and this allows the expensive resources to be shared.In other words, when each surrogate process creates an in-process thumbnail extractor, don't do the extraction in the surrogate process:Surrogate 1 Surrogate 2Plug-in↓Resources Plug-in↓ResourcesInstead, put the extraction in the shared local server, so that one server does all the extracting and can reuse the expensive resources. Surrogate 1 Local server Surrogate 2  Plug-in    →   ↙Extractor↘ Factory↓↓↓Resource ↘Extractor↙   ←    Plug-in  The local server can follow the traditional pattern of shutting down if all COM objects have been destroyed and no new ones have been created for 30 seconds.The factory object is registered with COM via Co­Register­Class­Object as with any other COM local server. Register it as multiple-use so that all the plug-ins will share the same server.The factory object can obtain the resources the first time it is asked to create an extractor, and then pass a shared reference to the resource to the extractor. Once 30 seconds elapse without any extractor, the server can shut down by revoking the factory (which causes it to release the resources).Related reading: Forcing plug-ins to run in separate processes: How can I convert a third party in-process server so it runs in the COM surrogate?