Пример #1
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);
            }
        }
Пример #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;
				
			}
		}