Exemple #1
0
        /// <summary>
        /// Provides an asynchronous version of the GetRequestStream method.
        /// </summary>
        /// <param name="callback">The AsyncCallback delegate</param>
        /// <param name="state">An object containing state information for this asynchronous request</param>
        /// <returns>An IAsyncResult that references the asynchronous request</returns>
        public override IAsyncResult BeginGetRequestStream(AsyncCallback callback, object state)
        {
            GetRequestStreamDelegate getRequestStream = GetRequestStream;

            // The return call.  Store in the hashtable.
            IAsyncResult asyncResult = getRequestStream.BeginInvoke(callback, state);

            this.delegateTable[asyncResult] = getRequestStream;

            // Begin the result.
            return(asyncResult);
        }
Exemple #2
0
        /// <summary>
        /// Returns a Stream for writing data to the NNTP server.
        /// </summary>
        /// <param name="asyncResult">An IAsyncResult that references a pending request for a stream. </param>
        /// <returns>A Stream to write data to.</returns>
        public override Stream EndGetRequestStream(IAsyncResult asyncResult)
        {
            // Get the item from the hashtable.  If it doesn't exist, then raise an
            // exception.

            GetRequestStreamDelegate getRequestStream =
                (GetRequestStreamDelegate)this.delegateTable[asyncResult];

            if (getRequestStream == null)
            {
                throw new NntpWebException("GetRequestStreamDelegate for "
                                           + this.requestUri +
                                           "not found in delegates table of NntpWebRequest");
            }

            // Remove the item from the hashtable.
            this.delegateTable.Remove(asyncResult);

            // Finish off the call.
            return(getRequestStream.EndInvoke(asyncResult));
        }