Sreekumar P
Sreekumar P

Reputation: 6050

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

Upvotes: 5

Views: 9894

Answers (5)

SwDevMan81
SwDevMan81

Reputation: 49978

BackgroundWorker will run in the background and can be easily used to sync back updates to your GUI if needed.

Or use the Task Parallel Library...

Upvotes: 0

JeffO
JeffO

Reputation: 8043

A BackgroundWorker may be the easiest place to start. Put your code in the DoWork event.

Upvotes: 1

Ghyath Serhal
Ghyath Serhal

Reputation: 7632

You can do this by creating a windows service that host a wcf service, when the user click on the submit button you can send the request to the windows service and the windows service will run in the background event the user closes the window.

Upvotes: 4

Tim Barrass
Tim Barrass

Reputation: 4939

You might use the BackgroundWorker, depending on your context.

Upvotes: 0

Darin Dimitrov
Darin Dimitrov

Reputation: 1038710

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.

Upvotes: 5

Related Questions