private void Work() { try { while (isRunning) { if (api != null) { api.RequestHeartbeat(); } Thread.Sleep(GazeManager.Instance.HeartbeatMillis); } } catch (Exception e) { Debug.WriteLine("Exception while running GazeHeartbeat: e" + e.Message); } finally { Debug.WriteLine("GazeHeartbeat closing down"); } }