System.Runtime.Remoting.Channels.StreamHelper.BeginAsyncCopyStream C# (CSharp) Method

BeginAsyncCopyStream() static private method

static private BeginAsyncCopyStream ( Stream source, Stream target, bool asyncRead, bool asyncWrite, bool closeSource, bool closeTarget, AsyncCallback callback, Object state ) : IAsyncResult
source Stream
target Stream
asyncRead bool
asyncWrite bool
closeSource bool
closeTarget bool
callback AsyncCallback
state Object
return IAsyncResult
        internal static IAsyncResult BeginAsyncCopyStream(
            Stream source, Stream target, 
            bool asyncRead, bool asyncWrite,
            bool closeSource, bool closeTarget,
            AsyncCallback callback, Object state)
        {   
            AsyncCopyStreamResult streamState = new AsyncCopyStreamResult(callback, state);

            byte[] buffer = CoreChannel.BufferPool.GetBuffer();

            streamState.Source = source;
            streamState.Target = target;
            streamState.Buffer = buffer;
            streamState.AsyncRead = asyncRead;
            streamState.AsyncWrite = asyncWrite;
            streamState.CloseSource = closeSource;
            streamState.CloseTarget = closeTarget;

            try
            {
                AsyncCopyReadHelper(streamState);
            } 
            catch (Exception e)
            {
                streamState.SetComplete(null, e);
            }
            catch {
                streamState.SetComplete(null, new Exception(CoreChannel.GetResourceString("Remoting_nonClsCompliantException")));
            }

            return streamState;
        } // BeginAsyncCopyStream