Thread.DisableComObjectEagerCleanup Method

Turns off automatic cleanup of runtime callable wrappers (RCW) for the current thread.

Namespace:  System.Threading
Assembly:  mscorlib (in mscorlib.dll)

public void DisableComObjectEagerCleanup()

By default, the common language runtime (CLR) cleans up runtime callable wrappers automatically. The CLR pumps messages during the cleanup, which might cause reentrancy problems for a few applications that meet the following unusual criteria:

  • The application does its own message pumping.

  • The application needs to control precisely when message pumping occurs.

Such applications can use the DisableComObjectEagerCleanup method to prevent the CLR from doing automatic reclamation of runtime callable wrappers.

When this method has been called on a thread, automatic cleanup cannot be re-enabled for that thread. When your application is ready to clean up runtime callable wrappers, use the Marshal.CleanupUnusedObjectsInCurrentContext method to instruct the runtime to clean up all runtime callable wrappers in the current context. Message pumping occurs while the method executes.

.NET Framework

Supported in: 4.5, 4

.NET Framework Client Profile

Supported in: 4

  • SecurityCriticalAttribute 

    Requires full trust for the immediate caller. This member cannot be used by partially trusted or transparent code.

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft