Running Stored Procedures asynchronously

Posts   
 
    
carlwhite
User
Posts: 5
Joined: 21-Aug-2006
# Posted on: 05-Dec-2006 16:15:41   

Hello there

I'm using Llblgen Pro 2, self-servicing (2 class) scenario, C# Winforms 2.0 and SQL Server 2000.

I need to trigger some stored procedures to run various monthly jobs (for example to kick off ETL or process Analysis Services cubes) from my UI. However, I don't want the user to have to wait for the result as I have a simple notification system set up which sends them a message when the process is complete.

How can I simply invoke a stored procedure without waiting for it to complete in the UI? I'm sure it is possible in ADO.NET to make asynchronous calls to database processes.

It may be the case that I have to trigger a job but it would be neat to do it through the UI.

Any help appreciated! As ever, excuse my inexpertise and thanks for reading/writing on this forum everyone.

Carl White

jmeckley
User
Posts: 403
Joined: 05-Jul-2006
# Posted on: 05-Dec-2006 18:42:30   

Check out the BackgroundWorkerProcess class. This allows your code to execute async commands and then use the results of the async operation in the main thread of your app (GUI).

I confess I haven't worked with this much. I primarily design web apps. I came across this class researching async operations in asp.net.

mihies avatar
mihies
User
Posts: 800
Joined: 29-Jan-2006
# Posted on: 05-Dec-2006 22:06:23   

Yeah, BackgroundWorker class is the easiest way. Or you can go with delegates or Thread class.

carlwhite
User
Posts: 5
Joined: 21-Aug-2006
# Posted on: 05-Dec-2006 23:25:59   

Thanks for the replies - they're both ideas I'd considered, unfortunately. I was rather hoping I could simply kick off a stored procedure then simply ignore its progress and effectively discard any results, allowing my application's (asynchronous) notification process to clean up afterwards.

My concern is that the application may be shut down while the stored proc is running. I shall test to see what happens... Of course, my other option is to call the stored proc asynchronously in ADO.NET but I want to keep my data layer pure.

Thanks again for your replies.

Carl White

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005