views:

442

answers:

1

Can anyone give me an example scenario where Asynchronous Callback should be used in an Winforms Database application?

And also an example scenario where Asynchronous Callback must be used in an Winforms database application?

+1  A: 

I can't give you a sample of when you must use asynchronous calls, but in general you would want to make any database call that might take a long time in an asynchronous manner to keep your UI responsive and offer the user the possibility to cancel the operation. An given the nature of database call, most (if not all) of them would qualify.

Regarding the method of achieving the asynchronousity, I would probably prefer using a BackgroundWorker over using Begin/EndInvoke and IAsyncResult.

Fredrik Mörk
If I need to fetch a huge amount of data from the Database, why should I need to keep my UI responsive. Coz, the next operation of the UI should need those data. Other that cancelling, it should have no use.
JMSA
And also this only canceling operation can be done with Threads.
JMSA
@JMSA: yes, it can be done with threads (hence my question about clarification whether you ask about the `Begin/EndInvoke` approach or asynchronous calls in general. Regarding the use (regardless of method): cancelling may be the only valid user action, but the user could for instance resize the window. That will not be pretty if the UI thread is blocked waiting for the DB response. Also, Windows may start to report the app as "not responding", which is also not very pretty.
Fredrik Mörk