G
Guest
I have a remoting object, lets call it A, that fires an event to remotely
registered handlers, lets call it B.
The invocation is working OK and the remote handler B is handling the event
like it should.
But I need A to catch any exception thrown from the handler B, and also I
need that A will get the returned value returned by handler B.
For that I wrote:
private void ResultsHandler(IAsyncResult ar)
{
// Extract the delegate from the AsyncResult.
MyEventHandler handler =
(MyEventHandler)((System.Runtime.Remoting.Messaging.AsyncResult)ar).AsyncDelegate;
// Obtain the result which I do not have because the delegate is void,
// but still need to that in order to catch exception caused in the.
handler.EndInvoke(ar);
}
public void RemtinMethod(long[] IDs)
{
// I'm using the AsyncCallback and state Object to be able to catch
exception caused in the delegate asynchronous invocation.
AsyncCallback cb = new AsyncCallback(ResultsHandler);
Object state = new Object();
if( RemoveDefectHandler != null )
{
foreach( MyEventHandler handler in MyEventHandler.GetInvocationList() )
{
try
{
handler.BeginInvoke(IDs, cb, state);
}
catch( Exception )
{
throw;
}
}
}
}
But still I can not get the returned value, and I'm also not catching at A
any thrown exception from B.
What I'm I doing wrong?
Is there any difference if I using the VS2003 or the VS2005? If so, what is
it?
registered handlers, lets call it B.
The invocation is working OK and the remote handler B is handling the event
like it should.
But I need A to catch any exception thrown from the handler B, and also I
need that A will get the returned value returned by handler B.
For that I wrote:
private void ResultsHandler(IAsyncResult ar)
{
// Extract the delegate from the AsyncResult.
MyEventHandler handler =
(MyEventHandler)((System.Runtime.Remoting.Messaging.AsyncResult)ar).AsyncDelegate;
// Obtain the result which I do not have because the delegate is void,
// but still need to that in order to catch exception caused in the.
handler.EndInvoke(ar);
}
public void RemtinMethod(long[] IDs)
{
// I'm using the AsyncCallback and state Object to be able to catch
exception caused in the delegate asynchronous invocation.
AsyncCallback cb = new AsyncCallback(ResultsHandler);
Object state = new Object();
if( RemoveDefectHandler != null )
{
foreach( MyEventHandler handler in MyEventHandler.GetInvocationList() )
{
try
{
handler.BeginInvoke(IDs, cb, state);
}
catch( Exception )
{
throw;
}
}
}
}
But still I can not get the returned value, and I'm also not catching at A
any thrown exception from B.
What I'm I doing wrong?
Is there any difference if I using the VS2003 or the VS2005? If so, what is
it?