private void RunLogProcessingThread() { try { //TODO: check impersonation? //WindowsImpersonationContext wi = Sync.SyncThread.ApplicationIdentity.Impersonate(); //only do this processing if we need to... if (!Configuration.Current.Settings.Trace.EmailErrors) { return; } //wait a minute before we get started Thread.Sleep(TimeSpan.FromMinutes(1)); Agility.Web.Tracing.WebTrace.WriteVerboseLine("Starting offline processing thread."); Int64 minutes = 1; Int64 ERROR_CHECK_MINUTES = 15; Int64 CLEANUP_CHECK_MINUTES = 60; while (true) { try { if (minutes == 1 || minutes % ERROR_CHECK_MINUTES == 0) { Agility.Web.Tracing.WebTrace.WriteVerboseLine("Checking for errors in error log."); //do the error log check WebTrace.SendErrorSummary(); } } catch (Exception ex) { Agility.Web.Tracing.WebTrace.WriteException(ex); } Thread.Sleep(TimeSpan.FromMinutes(1)); minutes++; } } catch (ThreadAbortException) { //this will be called when the app is shutdown or the thread is killed } catch (Exception ex) { Agility.Web.Tracing.WebTrace.WriteException(ex); } finally { IsOfflineThreadRunning = false; } }