用两个不同的函数运行两个线程 [英] run two thread with two different function

查看:108
本文介绍了用两个不同的函数运行两个线程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




i想同时运行两个线程,两个线程都有不同的功能,



一个帖子:



CallFstThread(counter,strval,strcnt)



第二线程:



CallSndThread(newval,intpage,cntval)



两个线程应该一起运行



并想要检查两个线程是否都已完成(即等待两个线程完成)然后重定向



问候

Hi
i want to run two threads simultaneously , both threads have different functions,

One thread :

CallFstThread(counter,strval,strcnt)

Second thread:

CallSndThread(newval,intpage,cntval)

Both threads should run together

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

Regards

推荐答案

请看我对这个问题的评论。



重要的是,线程化是ASP.NET主要无用的。 ASP.NET代码仅在响应某些HTTP请求时执行,并且应该产生一些HTTP响应;并且在响应之后,代码的运行时结束。因此,页面代码的所有代码都应该很快完成。这使得线程和服务器端定时器几乎没用。



-SA
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.

—SA


1。 ASP.NET Web应用程序正在服务器上运行。后面的代码由尊重的一些严格规则(如事件顺序:Page_PreInit,Page_Init,Page_Load,...,Page_Prerender)执行,然后页面呈现,结果HTML被发送回使用它显示的Web浏览器网页。



您可以在此处阅读详细信息: ASP.NET页面生命周期概述 [ ^ ]



2.在某些用户操作上,例如按下按钮,页面将被发回从浏览器到Web服务器然后再次执行代码,就像我在上面的第1点所解释的那样。



3.所以,基于这些主要规则上面描述的ASP.NET Web应用程序,在与ASP.NET应用程序关联的代码中使用线程是没有意义的!
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!


这篇关于用两个不同的函数运行两个线程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆