Force asynchronous execution?

M

Marty McDonald

I'm creating a helper class which will make it easier to use another class.
The helper class will have one method (let's call it "Go") that will need to
perform extensive operations. Yet I want apps who use the helper class to
remain responsive. I think my options are...
A) Encourage consumers to invoke "Go" asynchronously (via documentation).
B) Implement "Go" so that it invokes a private method asynchronously, then
immediately returns.

I don't want the consumers to be burdened with events and/or threads. Is
this the best way to protect consumers from a lengthly wait?

Thanks!
 
N

Nicholas Paldino [.NET/C# MVP]

Marty,

I think that you should follow the asynchronous model that .NET has put
in place, using the "Begin<action>" and "End<action>" pattern that has been
established. This, in conjunction with the IAsyncResult interface (and
implementation) should give you everything that you need. You can easily
create an implementation by creating a delegate that matches the signature
of your method, and then just having your Begin and End methods call the
BeginInvoke and EndInvoke methods on a delegate instance pointing to your
method.

Hope this helps.
 
G

Guest

Hi Marty,

Does Nicholas's suggestion work for you? Is your problem resolved?

If you still have any concern, please feel free to feedback, I will help
you.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top