Пример #1
0
        public override Stream EndGetRequestStream(IAsyncResult asyncResult)
        {
            if (asyncResult == null)
            {
                throw new ArgumentNullException("asyncResult");
            }

            GHWebAsyncResult result = asyncResult as GHWebAsyncResult;

            if (result == null)
            {
                throw new ArgumentException("Invalid IAsyncResult");
            }

            _asyncWrite = result;

            result.WaitUntilComplete();

            Exception e = result.Exception;

            if (e != null)
            {
                throw e;
            }

            return(result.WriteStream);
        }
Пример #2
0
        public override IAsyncResult BeginGetRequestStream(AsyncCallback callback, object state)
        {
            lock (this)
            {
                if (_asyncWrite != null)
                {
                    throw new InvalidOperationException("Cannot re-call start of asynchronous " +
                                                        "method while a previous call is still in progress.");
                }

                _asyncWrite = new GHWebAsyncResult(this, callback, state);
                if (_hasRequest)
                {
                    if (_writeStream != null)
                    {
                        _asyncWrite.SetCompleted(true, _writeStream);
                        _asyncWrite.DoCallback();
                        return(_asyncWrite);
                    }
                }


                try
                {
                    this.GetRequestStream();
                }
                catch (Exception e)
                {
                    _asyncWrite.SetCompleted(false, e);
                    _asyncWrite.DoCallback();
                    return(_asyncWrite);
                }

                _asyncWrite.SetCompleted(true, _writeStream);
                _asyncWrite.DoCallback();
                return(_asyncWrite);
            }
        }
Пример #3
0
		public override Stream EndGetRequestStream(IAsyncResult asyncResult)
		{
			if (asyncResult == null)
				throw new ArgumentNullException ("asyncResult");

			GHWebAsyncResult result = asyncResult as GHWebAsyncResult;
			if (result == null)
				throw new ArgumentException ("Invalid IAsyncResult");

			_asyncWrite = result;

			result.WaitUntilComplete ();

			Exception e = result.Exception;
			
			if (e != null)
				throw e;

			return result.WriteStream;
		}
Пример #4
0
		public override IAsyncResult BeginGetRequestStream(AsyncCallback callback, object state)
		{
			lock(this)
			{
				if(_asyncWrite != null)
				{
					throw new InvalidOperationException ("Cannot re-call start of asynchronous " +
						"method while a previous call is still in progress.");
				}
	
				_asyncWrite = new GHWebAsyncResult (this, callback, state);
				if (_hasRequest) 
				{
					if (_writeStream != null) 
					{
						_asyncWrite.SetCompleted (true, _writeStream);
						_asyncWrite.DoCallback ();
						return _asyncWrite;
					}
				}
				
				
				try
				{
					this.GetRequestStream();					
				}
				catch(Exception e)
				{
					_asyncWrite.SetCompleted(false, e);
					_asyncWrite.DoCallback ();
					return _asyncWrite;
				}

				_asyncWrite.SetCompleted (true, _writeStream);
				_asyncWrite.DoCallback ();
				return _asyncWrite;
				
			}
		}