ThreadPool不启动任何新线程,但低于极限

发布于 2025-01-28 16:24:00 字数 1036 浏览 3 评论 0原文

我有一个使用异步任务从MQTT服务器获取数据的应用程序。 将系统更新为Windows 11后,我开始注意到问题是在应用程序运行几天后没有启动的异步任务。 这在我从Windows 10到Windows 11上升之前工作正常。 在检查调试器时,我注意到ThreadPool设置为至少16个任务,但目前只有1个任务女巫正在等待其他未启动的任务。 我还用windbg检查了一个转储,并从!threadpool获得了

CPU utilization: 9%
Worker Thread: Total: 1 Running: 0 Idle: 1 MaxLimit: 32767 MinLimit: 16
Work Request in Queue: 0
--------------------------------------
Number of Timers: 1
--------------------------------------
Completion Port Thread:Total: 1 Free: 1 MaxFree: 32 CurrentLimit: 1 MaxLimit: 1000 MinLimit: 16

我的代码基本上是基本的

Sub Test()
StartUpMQTT().Wait()
End Sub
Private Async Function StartUpMQTT() As Task
MQTTClient = Await Net.Mqtt.MqttClient.CreateAsync(strWebLink, Configuration) 'This is the Line where it waits for the unstarted task.
sessionState = Await MQTTClient.ConnectAsync(New MqttClientCredentials("TestAuslesung"))
End function

,现在我将startupmqtt()。等待()更改为startupmqtt()。等待(5000),但是我必须等待解决问题,如果解决问题了整个应用程序悬挂。

除了我的更改之外,我可以尝试防止这种情况发生/冻结应用程序吗?

I have a app that uses async tasks to get Data from a MQTT server.
After I updated my System to Windows 11 I started noticing the Problem that the async tasks are not starting after the App runs for some Days.
This Worked fine before I upraded from Windows 10 to Windows 11.
Checking with a Debugger, I noticed that the Threadpool is set to minimum 16 tasks, but currently only has 1 task witch is waiting for another tasks that is not starting.
I also checked a Dump with Windbg and got this Result from !ThreadPool

CPU utilization: 9%
Worker Thread: Total: 1 Running: 0 Idle: 1 MaxLimit: 32767 MinLimit: 16
Work Request in Queue: 0
--------------------------------------
Number of Timers: 1
--------------------------------------
Completion Port Thread:Total: 1 Free: 1 MaxFree: 32 CurrentLimit: 1 MaxLimit: 1000 MinLimit: 16

My Code is basicly

Sub Test()
StartUpMQTT().Wait()
End Sub
Private Async Function StartUpMQTT() As Task
MQTTClient = Await Net.Mqtt.MqttClient.CreateAsync(strWebLink, Configuration) 'This is the Line where it waits for the unstarted task.
sessionState = Await MQTTClient.ConnectAsync(New MqttClientCredentials("TestAuslesung"))
End function

For now I changed my StartUpMQTT().Wait() to StartUpMQTT().Wait(5000), but I have to wait if this solves the issue of the whole app hanging.

Anything I can try to prevent this from happening/freezing the app, other than my change?

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文