public object EndInvoke(IAsyncResult result)
{
var r = (AsyncResult)result;
try
{
r.Future.WaitEmpty();
}
catch (FutureException ex)
{
Contract.ThrowIfNull(ex.InnerException);
throw new InvocationException("Error during BeginInvoke", ex.InnerException);
}
finally
{
if (r.Handle != null)
{
r.Handle.Close();
r.Handle = null;
}
}
return r.Future.Wait();
}