public static void StartServerPing() { if (!string.IsNullOrEmpty(OrderSchemeParameters.СхемаПриказ.УникальныйИдентификаторСтанции)) { timer = EasyTimer.SetInterval(async() => { try { ВходнойСигнал = await HttpHelper.ПослатьИПолучитьСигнал(new SendSignalDTO { Signal = ShouldSendSignal ? N16Parameters.ВыходнойСигнал : null, Id = OrderSchemeParameters.СхемаПриказ.УникальныйИдентификаторСтанции }); } catch { StopServerPing(); ErrorEvent(); } }, 1000); } }
protected override void NotifyBack(IColorable from, BroadcastSignal signal) { bool contains; lock (BroadcastSignals) { contains = BroadcastSignals.Contains(signal); if (!contains) BroadcastSignals.Add(signal); } if (contains) System.Diagnostics.Debug.WriteLine(String.Format("\tBroadcast repeated {0} ({1}, color={2})", signal, ToString(), CurrentColor == null ? "null" : CurrentColor.ToStringDemuxed())); else System.Diagnostics.Debug.WriteLine(String.Format("\tBroadcast {0} ({1}, color={2})", signal, ToString(), CurrentColor == null ? "null" : CurrentColor.ToStringDemuxed())); signal.Process(this, contains); InvokeOnNotifyBack(); if (!contains) { SplitNotify(GetPrevPaths(), signal); } }
private void SplitNotify(IEnumerable<IColorable> connections, BroadcastSignal signal) { var colorables = connections as IColorable[] ?? connections.ToArray(); if (colorables.Count() == 1) { colorables.First().NotifyBack(this, signal); }else foreach (var connection in colorables) { IColorable connection1 = connection; new Thread( () => connection1.NotifyBack(this, signal) ) {IsBackground = true}.Start(); } }
protected abstract void NotifyBack(IColorable from, BroadcastSignal signal);