[Mono-dev] COM, Threads and Mono

Robert Jordan robertj at gmx.net
Fri Sep 2 13:30:22 EDT 2011


Hi Jonathan,

How about relying on System.Threading.SynchronizationContext.Current?
This could work w/out exposing any internal calls/env vars.

This way we offload the burden of implementing a suitable
SynchronizationContext on the COM consumer. Done ;)

The necessary runtime changes are as simple as this:

~__ComObject ()
{
	SynchronizationContext.Current.Post(delegate {
		 ReleaseInterfaces ();
	});
}

Consumers publish their own SynchronizationContext with
SynchronizationContext.SetSynchronizationContext(
	new MySuperCoolSyncContext());

Robert



More information about the Mono-devel-list mailing list