Hungry Mind , Blog about everything in IT - C#, Java, C++, .NET, Windows, WinAPI, ...

How to call GC.WaitForPendingFinalizers via CLR interop interfaces

HRESULT WaitForPendingFinalizers()
{
   const ATL::CComSafeArray<IUnknown *> assemblies = DefaultDomain()->GetAssemblies();
   const auto pAssemblyThunk = assemblies.GetAt(assemblies.GetLowerBound());
   const _AssemblyPtr pMsCorLibAssembly = pAssemblyThunk.p;
   const auto pGCType = pMsCorLibAssembly->GetType_2(L"System.GC");
   const BindingFlags bFlags = static_cast(BindingFlags_InvokeMethod | BindingFlags_Static | BindingFlags_Public);
   ATL::CComVariant vtTarget;
   ATL::CComSafeArray<VARIANT> saMethodArgs;
   const HRESULT hr = pGCType->InvokeMember_3(L"WaitForPendingFinalizers", bFlags, NULL, vtTarget, saMethodArgs);
   return hr;
}

1 коммент.:

Анонимный комментирует...

modern combat 5 mod apk

Отправить комментарий

Copyright 2007-2011 Chabster