private void SetBeginReceiveCallback(byte[] buffer) { if (ReadTimeout != TimeSpan.MaxValue) { AsyncSetTimeout = new SetTimeoutDelegate(SetTimeout); } try { ClientSocket.BeginReceive(buffer, 0, BufferSize, 0, new AsyncCallback(DataReceived), null); if (AsyncSetTimeout != null) { AsyncSetTimeout(); } } catch (System.ObjectDisposedException) { if (_receiving || _isDisposed) { Log.Info(_id + ": Stopped Waiting for data because disposing."); } else { throw; } } catch (SocketException) { if (_receiving || _isDisposed) { Log.Info(_id + ": Stopped Waiting for data because disposing or Timed Out."); } else { throw; } } }
private void SetBeginReceiveCallback(byte[] buffer) { if(ReadTimeout != TimeSpan.MaxValue) AsyncSetTimeout = new SetTimeoutDelegate(SetTimeout); try { ClientSocket.BeginReceive( buffer, 0, BufferSize, 0, new AsyncCallback(DataReceived), null); if(AsyncSetTimeout != null) AsyncSetTimeout(); } catch(System.ObjectDisposedException) { if(_receiving || _isDisposed) Log.Info(_id + ": Stopped Waiting for data because disposing."); else throw; } catch(SocketException) { if(_receiving || _isDisposed) Log.Info(_id + ": Stopped Waiting for data because disposing or Timed Out."); else throw; } }