为什么当我同时使用不同的浏览器运行我的应用程序时,threadID 相同?

发布于 2024-09-09 09:08:25 字数 287 浏览 4 评论 0原文

我有一个简单的应用程序,其中包含一个单击按钮即可开始日志记录,基本上我将消息记录到数据库中。该应用程序已设置为将消息记录到数据库中。因此,我尝试在我的机器上运行我的应用程序,但同时使用两种不同的浏览器,例如(google chrome 和 Internet Explorer)。我从两个浏览器中单击了按钮,但奇怪的是两个浏览器的 threadID 是相同的。但是,当我在同一浏览器上运行该应用程序多次时,每次执行它时它都会给出一个新的 threadID。为什么? 由于执行时间不同,因此当我同时从不同浏览器运行应用程序时,我预计 threadID 会有所不同。

I have a simple application that contains one button to be clicked in order to start logging, and basically I log messages to database. The application is already set up to log messages to a database. So, I tried to run my application in my machine but with two different browsers, for example( google chrome and Internet Explorer) at the same time. And i click the button from both browsers, but the strange thing is the threadID is the same for both browsers. However, when I run the application on same browser several times it does give a new threadID each time I execute it. WHY?
As I was expecting the threadID to be different when i run the app from different browsers simultaneously since the execution time was different.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

删除→记忆 2024-09-16 09:08:25

ThreadID与浏览器无关;它与运行服务器代码的线程有关。也就是说,aspnet 工作进程(或任何运行您正在登录的代码段的进程)。

The ThreadID has nothing to do with the browser; it has to do with the Thread running the server code. That is to say, the aspnet worker process (or whatever is running the piece of code you're logging from).

铜锣湾横着走 2024-09-16 09:08:25

服务器重用线程来处理传入请求(无论您使用什么浏览器、使用什么计算机登录等)。我可以将浏览器指向您的服务器,并获得与您所看到的相同的 ThreadId。无法保证(据我所知)您的代码将在多个请求的不同线程上运行。也不能保证(据我所知)您的代码将跨多个请求在同一线程上运行。

The server reuses threads to handle incoming requests (regardless of what browser you're using, what computer you're logging in with, etc.). I could point my browser at your server, and get the same ThreadId's as you're seeing. There's no guarantee (as far as I know) that your code will run on different threads across multiple requests. There's also no guarantee (as far as I know) that your code will run on the same thread across multiple requests.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文