public string EndExecute(IAsyncResult asyncResult)
{
if (asyncResult == null)
{
throw new ArgumentNullException("asyncResult");
}
var commandAsyncResult = asyncResult as CommandAsyncResult;
if (commandAsyncResult == null || _asyncResult != commandAsyncResult)
{
throw new ArgumentException(string.Format("The {0} object was not returned from the corresponding asynchronous method on this class.", typeof(IAsyncResult).Name));
}
lock (_endExecuteLock)
{
if (commandAsyncResult.EndCalled)
{
throw new ArgumentException("EndExecute can only be called once for each asynchronous operation.");
}
// wait for operation to complete (or time out)
WaitOnHandle(_asyncResult.AsyncWaitHandle);
UnsubscribeFromEventsAndDisposeChannel(_channel);
_channel = null;
commandAsyncResult.EndCalled = true;
return Result;
}
}