简体   繁体   中英

ASP.NET - run SQL Agent in background

I need to start up a SQL Agent job when I click on some buttons on my ASP.NET page.

How do I let the job run in background without letting my ASP.NET page wait for the job to finish?

The idea is that one the button is clicked, the SQL Agent job does it's own stuff in the background without affecting my page.

I have something like this now:

SqlCommand cmd = new SqlCommand(“EXEC sp_start_job @Job_Name = ‘” + JobName + “‘”, conn);
cmd.CommandTimeout = 30;
cmd.ExecuteNonQuery();

'sp_start_job'本质上应该是异步的,它不会等待作业完成。

您可以使用异步过程执行

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM