Call asynchronously

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

For example, I've implemented a simple class with just one method:

public class A
{
public void MyMethod1()
{
// implementation
}
}


My questions relate to the implementation of this method.

1. How is it possible to understand whether this method has been called
syncrhonously or asynchronously (via delegate.BeginInvoke).
2. How is it possible to get an IAsyncResult associated with the current
asynchronous invocation.
3. How is it possible to intercept asynchronous invocation (initiated via
delegate.BeginInvoke), so it will use two additional methods instead, i.e.


public class A
{
public void MyMethod1()
{
// implementation
}

public void MyMethod1Begin(parameters, IAsyncResult, ...)
{
// implementation
}

public void MyMethod1End(IAsyncResult)
{
// implementation
}
}


Regards
 
There is no straightforward way to do this. The only thing i can think of is
that you walk the call stack using StackFrame class and determine if the
caller is an instance of the delegate class. Still that wouldn't solve your
problem of getting the AsyncResult object.

Can you tell me why do you have this requirement, maybe an alternate design
is possible.
 
Back
Top