Click here to Skip to main content
15,746,064 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

I need to run a background process on a button click on a web page and the page shoud not hang/wait to complete the process so that user can do whatever he wants to do on the webapp.

My solutions:

1) I used BackgroundWorker class and even if I close the UI job gets done but if I dont close UI, It gets hang untill process gets complete.

2) I used webservice and used backgroundworker clas in WS. But it shows same result as the 1st one .. :(

Please help me .. I need UI to be free .. while workingon background job..

Thanks in advance.


[edit]Removed "urgent" from subject[edit]
Updated 18-Dec-10 5:36am
[no name] 18-Dec-10 11:40am    
Don't ask for urgent help, its rude. This is a volunteer site and people will answer on their time, not yours.

You need to understand ASP.NET processing. During a postback it doesn't matter how many threads you spawn the page will not be rendered until all of completed.

If you want asynchronous processing then look into AJAX, either by using a simple UpdatePanel, or more direct means, such as JQuery.
Share this answer
Divymital 18-Dec-10 11:42am    
Thanks for reply, But the problem is that the job takes like 15 - 20 sec and req is to have this job at back end make the UI free from it so that user can do what ever he wants. I used BackgroundWorker for the same. If I will use Ajax it maked Ui freeze which I dont want. Please suggest .. Thanks again.. :)
[no name] 18-Dec-10 11:58am    
AJAX WILL NOT FREEZE THE UI!!!! It is an out of band call. You are most likely not using AJAX or using it incorrectly. Take some time to actually learn the technique. BackgoundWorker is not for ASP.NET.
Private Sub DoSomethingInBackGround()
End Sub

Protected Sub btnRunInBackGround_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnRunInBackGround.Click
        Dim backGroundThreadStart As New Threading.ThreadStart(AddressOf DoSomethingInBackGround)
        Dim backGroundThread As New Threading.Thread(backGroundThreadStart)
End Sub
Share this answer
[no name] 19-Dec-10 10:47am    
BackgroundWorker should not be used in ASP.NET pages. Look at Asynchronous Pages instead.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900