Ejemplo n.º 1
0
        /// <summary>
        /// Copies a stream asynchronously. This method is useful for copying data to a network stream because the network stream
        /// will actually buffer at the hardware level and the calling thread will not have to block. when the asynchronous copy
        /// has complete, the delegate specified by the endHandler argument will be called to complete the operation
        /// </summary>
        /// <param name="inSource">The stream to copy from</param>
        /// <param name="inDestination">The stream to copy to. Flush() will be called when the copy is complete</param>
        /// <param name="endHandler">The delegate to call when the async copy operation is complete</param>
        /// <param name="state">The state, if any that the delegate would like returned to it</param>
        public static void BeginCopyStream(Stream inSource,
                                           Stream inDestination,
                                           int bufferSize,
                                           EduAsyncHandler endHandler,
                                           object state)
        {
            AsyncStreamState streamState =
                new AsyncStreamState(inSource, inDestination, bufferSize, endHandler, state);

            DoAsyncCopyStep(streamState);
        }
Ejemplo n.º 2
0
 public AsyncStreamState(Stream sourceStream,
                         Stream destinationStream,
                         int bufferSize,
                         EduAsyncHandler finishedHandler,
                         object finishedHandlerState)
     : base(finishedHandler, finishedHandlerState)
 {
     fSourceStream      = sourceStream;
     fDestinationStream = destinationStream;
     fBufferSize        = bufferSize;
     fBuffer            = new byte[fBufferSize];
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Creates an instance of an EduAsyncResult
 /// </summary>
 /// <param name="handler">The delegate the will accept the result of the asynchronous invocation</param>
 /// <param name="state">The state, if necessary to be returned to the result delegate</param>
 public EduAsyncResult(EduAsyncHandler handler,
                       object state)
 {
     fAsyncDelegate = handler;
     fState         = state;
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Creates an instance of an EduAsyncResult
 /// </summary>
 /// <param name="handler">The delegate the will accept the result of the asynchronous invocation</param>
 /// <param name="state">The state, if necessary to be returned to the result delegate</param>
 public EduAsyncResult( EduAsyncHandler handler,
                        object state )
 {
     fAsyncDelegate = handler;
     fState = state;
 }
Ejemplo n.º 5
0
 public AsyncStreamState( Stream sourceStream,
                          Stream destinationStream,
                          int bufferSize,
                          EduAsyncHandler finishedHandler,
                          object finishedHandlerState )
     : base(finishedHandler, finishedHandlerState)
 {
     fSourceStream = sourceStream;
     fDestinationStream = destinationStream;
     fBufferSize = bufferSize;
     fBuffer = new byte[fBufferSize];
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Copies a stream asynchronously. This method is useful for copying data to a network stream because the network stream 
 /// will actually buffer at the hardware level and the calling thread will not have to block. when the asynchronous copy
 /// has complete, the delegate specified by the endHandler argument will be called to complete the operation
 /// </summary>
 /// <param name="inSource">The stream to copy from</param>
 /// <param name="inDestination">The stream to copy to. Flush() will be called when the copy is complete</param>
 /// <param name="endHandler">The delegate to call when the async copy operation is complete</param>
 /// <param name="state">The state, if any that the delegate would like returned to it</param>
 public static void BeginCopyStream( Stream inSource,
                                     Stream inDestination,
                                     int bufferSize,
                                     EduAsyncHandler endHandler,
                                     object state )
 {
     AsyncStreamState streamState =
         new AsyncStreamState( inSource, inDestination, bufferSize, endHandler, state );
     DoAsyncCopyStep( streamState );
 }