void GcmEntryPoint()
{
while(_gcmRunning)
{
DateTime now = DateTime.Now;
if(now >= _nextForcedCollection)
{
if(_lastKnownWorkingSet == -1L)
{
_lastKnownWorkingSet = GC.GetTotalMemory(true);
}
else
{
bool shouldCollect = (_lastKnownWorkingSet / 1024L / 1024L) > _minimumWorkingSet;
if(shouldCollect)
{
WriteLine("Collecting...");
_lastKnownWorkingSet = GC.GetTotalMemory(true);
now = DateTime.Now;
}
else
_lastKnownWorkingSet = GC.GetTotalMemory(false);
}
_nextForcedCollection = now.AddSeconds(5.0);
}
else
{
Thread.Sleep(512);
}
}
}