Click here to Skip to main content
15,742,619 members
Please Sign up or sign in to vote.
2.00/5 (2 votes)
See more:
i want to run two threads simultaneously , both threads have different functions,

One thread :


Second thread:


Both threads should run together

and want check if both threads have finished (ie.wait for both to finish ) and then redirect

Sergey Alexandrovich Kryukov 4-Jul-14 2:43am    
A thread is not something which can be called. The meaning of the thread is very different. I would prefer advising: use threading from the very beginning.

Please see my comment to the question.

Importantly, threading is ASP.NET is majorly useless. ASP.NET code is only executed in response to some HTTP request and should produce some HTTP response; and after the response the runtime of your code behind ends. So, all the code of your page's code behind should be complete fairly quickly. This makes threads and server-side timers pretty much useless.

Share this answer
Raul Iloc 4-Jul-14 2:49am    
Why did you vote me with 1, I was the first that put a correct answer to this question?
Sergey Alexandrovich Kryukov 4-Jul-14 2:58am    
Why are you saying this? I did not vote. Let me ask you, too: did you vote 1 for this my answer? Maybe, someone else voted 1 for both our answers. Now I can see 2 down-voted on your answer; it's hard to explain it.

By the way, referring to "I was the first" is pointless, because it's pretty much apparent that you posted your answer when I was typing mine; it happens all the time. Anyway, please be careful if you want to accuse anyone. I do down-vote some answers, but I would never do such thing you though I did.

Now, your answer is good enough for me to vote 5; and this is not to counter-vote, but because I really agree with your answer and appreciate it.

Raul Iloc 4-Jul-14 3:02am    
Sorry then, I saw that the downgrade vote comes almost at the same moment with your answer.
It is strange that now I have 2 votes with value 1 for a good answer.

PS: I just vote you with 5.
1.The ASP.NET web application are running on the server. The code behind is executed by respected some strict rules (like event order: Page_PreInit, Page_Init, Page_Load, ..., Page_Prerender) and at they the page is rendering and the resulted HTML is sent back to the web browser that use it to display the web page.

You can read details here: ASP.NET Page Life Cycle Overview[^]

2.On some user actions, like pressing a button, the page is sent back from the browser to the web server and then the code behind is executed again, like I explained at 1st point above.

3.So, based on these main rules about ASP.NET web application described above, it make no sense to use threads in the code behind associated with an ASP.NET application!
Share this answer
maulikshah1990 4-Jul-14 3:06am    
Hi Raul,

What i have asked is totally different from your above post...?

Pls advice..
Raul Iloc 4-Jul-14 4:17am    
Your question was about using threads in ASP.NET application and I explained in my solution why the using of threads in the case of ASP.NET web applications make no sense!

So what are your trying to use the threads in your web application? What are you trying to do with them?

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