Well, the easiest way to do this is to create a delegate with the same
signature as foo, like so:
private delegate void AsyncFoo(FooParams fooParams);
Then implement your BeginFoo like so:
private static AsyncFoo asyncFoo;
public static IAsyncResult BeginFoo(FooParams fooParams, AsyncCallback
callback, object state)
{
// Store asyncFoo.
asyncFoo = new AsyncFoo(Foo);
// Make the call.
return asyncFoo.BeginInvoke(fooParams, callback, state);
}
public static void EndFoo(IAsyncResult result)
{
// Finish the call.
asyncFoo.EndInvoke(result);
}
If you are going to have multiple calls to BeginFoo, then you are going
to have to manage the asyncFoo field so that you don't have mismatched
begin/end calls.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
-
mvp@spam.guard.caspershouse.com
"intrader" <intrader@aol.comwrote in message
news:4623ff7a$0$4934$4c368faf@roadrunner.com...
Quote:
What I have is a class A with a method Foo. I would like to create a
thread that instances A and then calls Foo asynchronously while performing
other duties.
>
I think that the solution is to write an asynchronous version of Foo so
that the caller can pass a callback as in the signature:
>
public static IAsyncResult Foo(
FooParams fooParams,
AsyncCallback requestCallback,
object StateObject
);
>
Is this possible?
>
Thanks