public override IAsyncResult BeginGetRequestStream(AsyncCallback callback, object state)
{
GlobalLog.Enter("FileWebRequest::BeginGetRequestStream");
try {
if (Aborted)
{
throw ExceptionHelper.RequestAbortedException;
}
if (!CanGetRequestStream())
{
Exception e = new ProtocolViolationException(SR.GetString(SR.net_nouploadonget));
GlobalLog.LeaveException("FileWebRequest::BeginGetRequestStream", e);
throw e;
}
if (m_response != null)
{
Exception e = new InvalidOperationException(SR.GetString(SR.net_reqsubmitted));
GlobalLog.LeaveException("FileWebRequest::BeginGetRequestStream", e);
throw e;
}
lock (this) {
if (m_writePending)
{
Exception e = new InvalidOperationException(SR.GetString(SR.net_repcall));
GlobalLog.LeaveException("FileWebRequest::BeginGetRequestStream", e);
throw e;
}
m_writePending = true;
}
//we need to force the capture of the identity and context to make sure the
//posted callback doesn't inavertently gain access to something it shouldn't.
m_ReadAResult = new ContextAwareResult(true, true, true, this, state, callback);
lock (m_ReadAResult.StartPostingAsyncOp())
{
ThreadPool.UnsafeQueueUserWorkItem(s_GetRequestStreamCallback, m_ReadAResult);
m_ReadAResult.FinishPostingAsyncOp();
}
} catch (Exception exception) {
if (Logging.On)
{
Logging.Exception(Logging.Web, this, "BeginGetRequestStream", exception);
}
throw;
} finally {
GlobalLog.Leave("FileWebRequest::BeginGetRequestSteam");
}
return(m_ReadAResult);
}