public void Start() { TaleWorlds.Library.Debug.Print("Starting ApplicationHealthChecker"); try { File.WriteAllText(BasePath.Name + "Application.HealthCheckerStarted", "..."); } catch (Exception ex) { ApplicationHealthChecker.Print("Blocked main thread file create e: " + (object)ex); } this._isRunning = true; this._stopwatch = new Stopwatch(); this._stopwatch.Start(); this._thread = new Thread(new ThreadStart(this.ThreadUpdate)); this._thread.IsBackground = true; this._thread.Start(); }
private void ThreadUpdate() { while (this._isRunning) { long num = this._stopwatch.ElapsedMilliseconds / 1000L; if (num > 180L) { ApplicationHealthChecker.Print("Main thread is blocked for " + (object)num + " seconds"); try { File.WriteAllText(BasePath.Name + "Application.Blocked", num.ToString()); } catch (Exception ex) { ApplicationHealthChecker.Print("Blocked main thread file create e: " + (object)ex); } try { ApplicationHealthChecker.Print("Blocked main thread IsAlive: " + this._mainThread.IsAlive.ToString()); ApplicationHealthChecker.Print("Blocked main thread ThreadState: " + (object)this._mainThread.ThreadState); } catch (Exception ex) { ApplicationHealthChecker.Print("Blocked main thread e: " + (object)ex); } } else { try { if (File.Exists(BasePath.Name + "Application.Blocked")) { File.Delete(BasePath.Name + "Application.Blocked"); } } catch (Exception ex) { ApplicationHealthChecker.Print("Blocked main thread file delete e: " + (object)ex); } } Thread.Sleep(10000); } }