diff -up pegasus/src/Pegasus/ProviderManagerService/ProviderAgent/ProviderAgent.cpp.test pegasus/src/Pegasus/ProviderManagerService/ProviderAgent/ProviderAgent.cpp --- pegasus/src/Pegasus/ProviderManagerService/ProviderAgent/ProviderAgent.cpp.test 2011-08-11 14:12:36.000000000 +0200 +++ pegasus/src/Pegasus/ProviderManagerService/ProviderAgent/ProviderAgent.cpp 2013-05-28 09:50:56.639410167 +0200 @@ -923,6 +928,19 @@ void ProviderAgent::_unloadIdleProviders PEG_TRACE_CSTRING(TRC_PROVIDERAGENT, Tracer::LEVEL1, "Could not allocate thread to unload idle providers."); } + + // Wait for the cleanup thread to finish + Uint64 shutdownTimeout = 0; + StringConversion::stringToUnsignedInteger( + PEGASUS_DEFAULT_SHUTDOWN_TIMEOUT_SECONDS_STRING, + shutdownTimeout); + + while ((_unloadIdleProvidersBusy.get() > 0) && (shutdownTimeout > 0)) { + Threads::yield(); + Threads::sleep(1000); + shutdownTimeout--; + } + PEG_METHOD_EXIT(); }