System.Net.Mail.Message.EndSend C# (CSharp) Method

EndSend() private method

private EndSend ( IAsyncResult asyncResult ) : void
asyncResult IAsyncResult
return void
        internal virtual void EndSend(IAsyncResult asyncResult)
        {
            if (asyncResult == null)
            {
                throw new ArgumentNullException(nameof(asyncResult));
            }

            if (Content != null)
            {
                Content.EndSend(asyncResult);
            }
            else
            {
                LazyAsyncResult castedAsyncResult = asyncResult as LazyAsyncResult;

                if (castedAsyncResult == null || castedAsyncResult.AsyncObject != this)
                {
                    throw new ArgumentException(SR.net_io_invalidasyncresult);
                }

                if (castedAsyncResult.EndCalled)
                {
                    throw new InvalidOperationException(SR.Format(SR.net_io_invalidendcall, nameof(EndSend)));
                }

                castedAsyncResult.InternalWaitForCompletion();
                castedAsyncResult.EndCalled = true;
                if (castedAsyncResult.Result is Exception)
                {
                    throw (Exception)castedAsyncResult.Result;
                }
            }
        }

Usage Example

Esempio n. 1
0
 internal void EndSend(IAsyncResult asyncResult)
 {
     _message.EndSend(asyncResult);
 }