public void Stop(string listenerName, string comPort) { string key = string.Empty; if (((listenerName != null) && (listenerName.Length != 0)) && ((comPort != null) && (comPort.Length != 0))) { if (listenerName.Contains(@".\private$\")) { key = listenerName; } else { key = @".\private$\" + listenerName + "_" + comPort; } if (this.ListenerList.ContainsKey(key)) { ListenerContent content = (ListenerContent)this.ListenerList[key]; if (content.State) { lock (this.ListenerLock) { content.State = false; content.QueueData.Clear(); } } } } }
private void doMainWork(object sender, DoWorkEventArgs e) { ListenerContent argument = (ListenerContent)e.Argument; Thread.CurrentThread.CurrentCulture = clsGlobal.MyCulture; Label_001B: if (argument.DoMainWork.CancellationPending) { argument.DoUserWork.CancelAsync(); e.Cancel = true; } else { if (!argument.DoUserWork.IsBusy && (argument.QueueData.Count > 0)) { MessageQData data = (MessageQData)argument.QueueData.Dequeue(); argument.DoUserWork.RunWorkerAsync(data); } if (argument.QueueData.Count > 20) { Thread.Sleep(100); } else { Thread.Sleep(20); } goto Label_001B; } }
public void Start(string listenerName, string comPort) { string key = string.Empty; if (((listenerName != null) && (listenerName.Length != 0)) && ((comPort != null) && (comPort.Length != 0))) { if (listenerName.Contains(@".\private$\")) { key = listenerName; } else { key = @".\private$\" + listenerName + "_" + comPort; } if (this.ListenerList.ContainsKey(key)) { ListenerContent argument = (ListenerContent)this.ListenerList[key]; if (!argument.State) { argument.State = true; if (!argument.DoMainWork.IsBusy) { argument.DoMainWork.RunWorkerAsync(argument); } } } } }
public virtual ListenerContent Create(string listenerName, int source, int chan, int msgId, int subId, string thisCom) { if (((listenerName == null) || (listenerName.Length == 0)) || ((thisCom == null) || (thisCom.Length == 0))) { return(null); } string key = @".\private$\" + listenerName + "_" + thisCom; ListenerContent content = null; lock (this.ListenerLock) { if (this.ListenerList.ContainsKey(key)) { return((ListenerContent)this.ListenerList[key]); } BackgroundWorker worker = new BackgroundWorker(); BackgroundWorker worker2 = new BackgroundWorker(); worker.WorkerSupportsCancellation = true; worker2.WorkerSupportsCancellation = true; worker2.DoWork += new DoWorkEventHandler(this.doMainWork); content = new ListenerContent(); content.ListenerName = key; content.Source = source; content.Chan = chan; content.MsgId = msgId; content.SubId = subId; content.ComPort = thisCom; content.DoUserWork = worker; content.DoMainWork = worker2; this.ListenerList.Add(key, content); } return(content); }
public void Stop() { foreach (string str in this.ListenerList.Keys) { ListenerContent content = (ListenerContent)this.ListenerList[str]; this.Stop(content.ListenerName); } }
public void Start() { lock (this.ListenerLock) { foreach (string str in this.ListenerList.Keys) { ListenerContent content = (ListenerContent)this.ListenerList[str]; this.Start(content.ListenerName); } } }
public void Stop(string listenerName) { if (((listenerName != null) && (listenerName.Length != 0)) && this.ListenerList.ContainsKey(listenerName)) { ListenerContent content = (ListenerContent)this.ListenerList[listenerName]; if (content.State) { lock (this.ListenerLock) { content.State = false; content.QueueData.Clear(); } } } }
public void Start(string listenerName) { if (((listenerName != null) && (listenerName.Length != 0)) && this.ListenerList.ContainsKey(listenerName)) { ListenerContent argument = (ListenerContent)this.ListenerList[listenerName]; if (!argument.State) { argument.State = true; if (!argument.DoMainWork.IsBusy) { argument.DoMainWork.RunWorkerAsync(argument); } } } }
public void DeleteAllListeners() { lock (this.ListenerLock) { foreach (string str in this.ListenerList.Keys) { ListenerContent content = (ListenerContent)this.ListenerList[str]; if (content.DoUserWork != null) { content.DoUserWork.CancelAsync(); } if (content.DoMainWork != null) { content.DoMainWork.CancelAsync(); } } this.ListenerList.Clear(); } }
public void DeleteListener(string listenerName) { string str = string.Empty; if ((listenerName != null) && (listenerName.Length != 0)) { Hashtable hashtable = new Hashtable(); lock (this.ListenerLock) { foreach (string str2 in this.ListenerList.Keys) { ListenerContent content = (ListenerContent)this.ListenerList[str2]; if (listenerName.Contains(@".\private$\")) { str = listenerName; } else { str = @".\private$\" + listenerName + "_" + content.ComPort; } if (content.ListenerName == str) { if (content.DoUserWork != null) { content.DoUserWork.CancelAsync(); } if (content.DoMainWork != null) { content.DoMainWork.CancelAsync(); } } else { hashtable.Add(str2, content); } } this.ListenerList.Clear(); this.ListenerList = hashtable; } } }
public virtual ListenerContent Create(string listenerName, int source, int chan, int msgId, int subId, string thisCom) { if (((listenerName == null) || (listenerName.Length == 0)) || ((thisCom == null) || (thisCom.Length == 0))) { return null; } string key = @".\private$\" + listenerName + "_" + thisCom; ListenerContent content = null; lock (this.ListenerLock) { if (this.ListenerList.ContainsKey(key)) { return (ListenerContent) this.ListenerList[key]; } BackgroundWorker worker = new BackgroundWorker(); BackgroundWorker worker2 = new BackgroundWorker(); worker.WorkerSupportsCancellation = true; worker2.WorkerSupportsCancellation = true; worker2.DoWork += new DoWorkEventHandler(this.doMainWork); content = new ListenerContent(); content.ListenerName = key; content.Source = source; content.Chan = chan; content.MsgId = msgId; content.SubId = subId; content.ComPort = thisCom; content.DoUserWork = worker; content.DoMainWork = worker2; this.ListenerList.Add(key, content); } return content; }
public override ListenerContent Create(string listenerName, string comport) { if (((listenerName == null) || (listenerName.Length == 0)) || ((comport == null) || (comport.Length == 0))) { return(null); } ListenerContent content = null; switch (listenerName) { case "HWConfig": case "HWConfig_GUI": case "TimeAiding": case "TimeAiding_GUI": case "FreqAiding": case "FreqAiding_GUI": case "ApproxPosition": case "ApproxPosition_GUI": return(content); case "Nav": case "Nav_GUI": return(this.Create(listenerName, 0, -1, 0x29, -1, comport)); case "TTFF": case "TTFF_GUI": return(this.Create(listenerName, 0, -1, 0xe1, 6, comport)); case "ClockStatus": case "ClockStatus_GUI": return(this.Create(listenerName, 0, -1, 7, -1, comport)); case "MeasuredNavigationData": case "MeasuredNavigationData_GUI": case "GeodeticNavigationData": case "GeodeticNavigationData_GUI": return(this.Create(listenerName, 0, -1, 0x29, -1, comport)); case "NavLibMeasurement": case "NavLibMeasurement_GUI": return(this.Create(listenerName, 0, -1, 0x1c, -1, comport)); case "PostionResponse": case "PostionResponse_GUI": return(this.Create(listenerName, 0, -1, 0x29, -1, comport)); case "SWVersion": case "SWVersion_GUI": return(this.Create(listenerName, 0, -1, 6, -1, comport)); case "CNO": case "CNO_GUI": return(this.Create(listenerName, 0, -1, 4, -1, comport)); case "SVS": case "SVS_GUI": if (base._rxType != CommunicationManager.ReceiverType.SLC) { return(this.Create(listenerName, 0, -1, 4, -1, comport)); } return(this.Create(listenerName, 0, 0xee, 4, -1, comport)); } return(content); }