public void EventProcessingLoop() { startSemaphore.WaitOne(); while (!stopped) { // Have a timer that signals the semaphore also callbackSemaphore.WaitOne(); if (!stopped && !startupError) { EHPMError result = SessionManager.Session.SessionProcess(); int iSeconds = 0; if (result == EHPMError.ConnectionLost) { do { logger.Warning("The connection to the Hansoft server was lost. A reconnection attempt will be made in 10 seconds."); Thread.Sleep(10000); iSeconds += 10; }while (!SessionManager.Instance.Reconnect()); logger.Information("The connection to the Hansoft server was restored after " + iSeconds + " seconds."); } else if (result != EHPMError.NoError) { logger.Warning("SessionProcess returned an error code: " + result.ToString()); } } else { SessionManager.Instance.CloseSession(); } } }