protected virtual void Dispose(bool disposing) { if (disposing) { if (waveSocket != null) { waveSocket.Dispose(); } if (waveDataproc != null) { waveDataproc.Dispose(); } if (StartRcvEvent != null) { StartRcvEvent.Dispose(); } if (StartRcvEvent != null) { StartRcvEvent.Dispose(); } if (RcvThread != null) { RcvThread.Abort(); RcvThread = null; } IsBuilded = false; IsStopRcved = true; linkbuffer.Clear(); Console.WriteLine(@"关闭UDP线程..."); } }
/// <summary> /// 开启接收接收数据 /// </summary> /// <param name="ip"></param> public void StartReceiveData(IPEndPoint ip) { Ip = ip; try { waveSocket.Bind(ip); IsBuilded = true; } catch (Exception e) { Console.WriteLine(@"创建UDP失败...错误为{0}", e); MessageBox.Show(@"创建UDP失败..."); } if (Equals(ip, ConstUdpArg.Src_NormWaveIp)) { WorktInit(); WaveType = ConstUdpArg.WaveType.Normal; } else if (Equals(ip, ConstUdpArg.Src_OrigWaveIp)) { OrigInit(); WaveType = ConstUdpArg.WaveType.Orig; } else if (Equals(ip, ConstUdpArg.Src_DelayWaveIp)) { DelayInit(); WaveType = ConstUdpArg.WaveType.Delay; } waveDataproc = new Dataproc(); waveDataproc.Init(WaveType); RcvThread.Start(); }
public virtual void Dispose() { try { RcvThread.Abort(); } catch { } try { SendThread.Abort(); } catch { } _newRcvTelegram.Dispose(); _newSendTelegram.Dispose(); _newSendNotifyTelegram.Dispose(); }
public virtual void StartCommunication() { RcvThread.Start(); SendThread.Start(); }
public void StopReceiveData() { StartRcvEvent.Reset(); RcvThread.Abort(); }