public ATFrame EndProcess(IAsyncResult asyncResult) { WaitingAsyncResult waitingAsyncResult = (WaitingAsyncResult)asyncResult; if (waitingAsyncResult.AsyncException != null) { throw waitingAsyncResult.AsyncException; } return((ATFrame)waitingAsyncResult.AsyncFrame); }
public IAsyncResult BeginProcess(ATFrame frame, bool waitResponse, int timeout, AsyncCallback callback, Object state) { lock (this.syncRoot) { lock (this.waitingLock) { this.waitingEcho = this.echoEnabled; this.waitingResponse = waitResponse; this.waitingTimeout = Environment.TickCount + timeout; this.waitingCommand = frame.Command; this.waitingCommandType = frame.CommandType; this.waitingCallback = callback; this.waitingAsyncResult = WaitingAsyncResult.GetInstance(); this.waitingAsyncResult.AsyncState = state; } try { this.sendingLength = frame.GetBytes(this.sendingBuffer, 0); this.stream.Write(this.sendingBuffer, 0, this.sendingLength); #if (DEBUG) Debug.Print("Sent frame > "); Debug.Print(new string(ATParser.Bytes2Chars(this.sendingBuffer, 0, this.sendingLength))); #endif return(this.waitingAsyncResult); } catch { lock (this.waitingLock) { this.waitingEcho = false; this.waitingResponse = false; } throw new ATModemException(ATModemError.Generic); } } }
public IAsyncResult BeginProcess(ATFrame frame, bool waitResponse, int timeout, AsyncCallback callback, Object state) { lock (this.syncRoot) { lock (this.waitingLock) { this.waitingEcho = this.echoEnabled; this.waitingResponse = waitResponse; this.waitingTimeout = Environment.TickCount + timeout; this.waitingCommand = frame.Command; this.waitingCommandType = frame.CommandType; this.waitingCallback = callback; this.waitingAsyncResult = WaitingAsyncResult.GetInstance(); this.waitingAsyncResult.AsyncState = state; } try { this.sendingLength = frame.GetBytes(this.sendingBuffer, 0); this.stream.Write(this.sendingBuffer, 0, this.sendingLength); #if (DEBUG) Debug.Print("Sent frame > "); Debug.Print(new string(ATParser.Bytes2Chars(this.sendingBuffer, 0, this.sendingLength))); #endif return this.waitingAsyncResult; } catch { lock (this.waitingLock) { this.waitingEcho = false; this.waitingResponse = false; } throw new ATModemException(ATModemError.Generic); } } }