Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run a Job in Background

I need a block of code which run a job in background. Suppose the user click on the Submit button, then a job starts in background, in the mean time the user closes that window and run a different job, and the job should keep running.

Please provide some help in ASP.NET and VB.NET.

Thank You Very Much For Your Help

like image 679
Sreekumar P Avatar asked Dec 15 '10 14:12

Sreekumar P


People also ask

How do I know if a job is running in the background?

The jobs command will show any background jobs started within the current shell, usually by starting a background task with the & operator or ^Z bg (e.g. sleep 10 & ). If you want to see all of the background processes running on the system, you can use ps -e , or ps -eF to get some additional details.

How do I run a background job in Unix?

Start the job as normal, then press CTRL-Z. It will say it is stopped, and then type "bg". It will continue in the background. Then type "fg", if you want it to run in the foreground again.

How do I send foreground job to background in Linux?

We can also send a foreground process to the background using the CTRL + Z shortcut. This shortcut will suspend the process; then, you can use the command bg to send it to the background.


1 Answers

You may take a look at the ThreadPool.QueueUserWorkItem method which allows you to run some some method on a thread drawn from the thread pool. As an alternative you could use the Thread class to spawn a new thread manually if it is a long running task to avoid jeopardizing a thread from the pool which contains a limited number of threads and which are also used to service requests in ASP.NET applications.

like image 71
Darin Dimitrov Avatar answered Sep 24 '22 21:09

Darin Dimitrov