Force asynchronous execution?

  • Thread starter Thread starter Marty McDonald
  • Start date Start date
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!
 
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.
 
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.
 
Back
Top