Skip to content

Instantly share code, notes, and snippets.

@sandrinodimattia
Created July 23, 2012 05:42
Show Gist options
  • Save sandrinodimattia/3162118 to your computer and use it in GitHub Desktop.
Save sandrinodimattia/3162118 to your computer and use it in GitHub Desktop.
COM cleanup
/// <summary>
/// Release a COM object so that it can be cleaned up.
/// </summary>
/// <param name="comObj"></param>
protected void ReleaseCom(dynamic comObj)
{
Marshal.ReleaseComObject(comObj);
}
/// <summary>
/// Clean up all released COM objects.
/// </summary>
protected void CleanAllReleased()
{
GC.Collect();
GC.WaitForPendingFinalizers();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment