System.Net.AsyncProtocolRequest.SetNextRequest C# (CSharp) Method

SetNextRequest() public method

public SetNextRequest ( byte buffer, int offset, int count, AsyncProtocolCallback callback ) : void
buffer byte
offset int
count int
callback AsyncProtocolCallback
return void
        public void SetNextRequest(byte[] buffer, int offset, int count, AsyncProtocolCallback callback)
        {
            if (_completionStatus != StatusNotStarted)
            {
                throw new InternalException(); // Pending operation is in progress.
            }

            Buffer = buffer;
            Offset = offset;
            Count = count;
            _callback = callback;
        }

Usage Example

 private void StartWriting(byte[] buffer, int offset, int count, AsyncProtocolRequest asyncRequest)
 {
     if (asyncRequest != null)
     {
         asyncRequest.SetNextRequest(buffer, offset, count, _ResumeAsyncWriteCallback);
     }
     if (count >= 0)
     {
         byte[] outBuffer = null;
         do
         {
             int num2;
             if (this._SslState.CheckEnqueueWrite(asyncRequest))
             {
                 return;
             }
             int num = Math.Min(count, this._SslState.MaxDataSize);
             SecurityStatus errorCode = this._SslState.EncryptData(buffer, offset, num, ref outBuffer, out num2);
             if (errorCode != SecurityStatus.OK)
             {
                 ProtocolToken token = new ProtocolToken(null, errorCode);
                 throw new IOException(SR.GetString("net_io_encrypt"), token.GetException());
             }
             if (asyncRequest != null)
             {
                 asyncRequest.SetNextRequest(buffer, offset + num, count - num, _ResumeAsyncWriteCallback);
                 IAsyncResult asyncResult = this._SslState.InnerStream.BeginWrite(outBuffer, 0, num2, _WriteCallback, asyncRequest);
                 if (!asyncResult.CompletedSynchronously)
                 {
                     return;
                 }
                 this._SslState.InnerStream.EndWrite(asyncResult);
             }
             else
             {
                 this._SslState.InnerStream.Write(outBuffer, 0, num2);
             }
             offset += num;
             count -= num;
             this._SslState.FinishWrite();
         }
         while (count != 0);
     }
     if (asyncRequest != null)
     {
         asyncRequest.CompleteUser();
     }
 }
All Usage Examples Of System.Net.AsyncProtocolRequest::SetNextRequest