标签:
public void Stop() { if (_serialPort != null) { if (_serialPort.IsOpen) { _serialPort.DataReceived -= _serialPort_GpsReceived; this._serialPort.DiscardInBuffer(); this._serialPort.DiscardOutBuffer(); int i = Environment.TickCount; while (Environment.TickCount - i < 2000 && _isReceiving) System.Windows.Forms.Application.DoEvents(); _serialPort.Close(); } this._serialPort.Dispose(); _serialPort = null; } }
_isReceiving:确保接收处理函数完成的标识
标签:
原文地址:http://www.cnblogs.com/moisten/p/4514741.html