public void Initialize() { if (_timer != null) { return; } _refreshCount = 60; CrestronEnvironment.ProgramStatusEventHandler += type => { _programStopping = type == eProgramStatusEventType.Stopping; if (_programStopping) { RequestQueue.Enqueue(null); } }; _timer = new CTimer(specific => { _refreshCount = _refreshCount - 1; try { if (_refreshCount == 0 || !Receivers.Any()) { Receivers.Discover(); } } catch (Exception e) { CloudLog.Error("Error getting receiver collection from AvediaServer, {0}", e.Message); } try { if (_refreshCount == 0 || !Channels.Any()) { Channels.UpdateChannels(); } } catch (Exception e) { CloudLog.Error("Error getting channel collection from AvediaServer, {0}", e.Message); } if (!_initialized) { _initialized = true; OnHasInitialized(this); } if (_refreshCount == 0) { _refreshCount = 60; } }, null, 1000, (long)TimeSpan.FromMinutes(1).TotalMilliseconds); }
public void Initialize() { if (_timer != null) { return; } _refreshCount = 60; _timer = new CTimer(specific => { _refreshCount = _refreshCount - 1; try { if (_refreshCount == 0 || !Receivers.Any()) { Receivers.Discover(); } } catch (Exception e) { CloudLog.Error("Error getting receiver collection from AvediaServer, {0}", e.Message); } try { if (_refreshCount == 0 || !Channels.Any()) { Channels.UpdateChannels(); } } catch (Exception e) { CloudLog.Error("Error getting channel collection from AvediaServer, {0}", e.Message); } if (!_initialized) { _initialized = true; OnHasInitialized(this); } if (_refreshCount == 0) { _refreshCount = 60; } }, null, 1000, (long)TimeSpan.FromMinutes(1).TotalMilliseconds); }