Delphi 多线程应用程序在 Vista 中内置,无法在 XP 中运行

发布于 2024-09-13 13:15:38 字数 616 浏览 7 评论 0原文

我真的很困惑。

我在 vista 上运行 delphi 2007。我已经构建了许多应用程序并在 XP 中运行它们没有任何问题。这个最新的应用程序必须使用线程。我很确定我的代码是正确的。它在 Vista 上运行良好,但是当我在 XP 上运行它(尝试了多台 PC)时,我的程序似乎滞后(操作系统的 32 位、XP sp3 和 Vista sp1、dotnet v2)。最好的例子是,如果我拔掉串口,我的coms将继续运行等。

我在我的xp机器上安装delphi,并在delphi运行时运行我的程序。就像我从 vista 内置的 exe 运行它一样。那时运行得很好。关闭delphi,comport又开始滞后。

如果我拔下并重新插入闪存驱动器,通讯器会再次恢复正常。

我想在我的 XP 机器上构建该应用程序,但拥有大约一百万个第三方组件,这使得安装成为一个真正的任务。

哦,仅供参考,我构建了一个简单的应用程序,仅包含主线程和一个comport 线程。同样的问题。 comthread 要做的就是从 comport 获取数据。甚至不显示它,我在后台使用串行端口监视器来检查延迟。

欢迎任何建议。

好的,快速编辑:XP 电脑是新构建的。我打开msn Messenger,程序运行正常。我显然缺少一些设置......

I am really stumped.

I am running delphi 2007 on vista. I have built many applications and run them in XP with no problem. This latest app had to make use of threads. I'm pretty sure my code is correct. It runs fine on Vista, but when I run it on XP (tried multiple PC's) my program seems to lag (both os's 32 bit, XP sp3 and Vista sp1, dotnet v2). Best example being if I unplug the serial port my coms will continue to run etc.

I was installing delphi on my xp machine, and ran my program while delphi was running. As in I ran it from the exe built in vista. It ran fine then. Close delphi, and the comport starts to lag again.

If I unplug and replug a flash drive, the coms catches up again.

I want to build the app on my xp based machine, but have like a million 3rd party components that makes it a real mission to setup.

Oh fyi, i built a simple application with just the main thread, and a comport thread. Same problem. All the comthread will do is fetch data off the comport. Not even display it, i used a serial port monitor in the background to check for the lag.

Any suggestions welcome.

OK quick edit: the XP pc is freshly built. I opened msn messenger, and the program runs fine. I'm obviously missing some setting...

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

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

发布评论

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

评论(2

脱离于你 2024-09-20 13:15:38

如果您在线程中使用Sleep(因此我对您的问题发表评论/查询),您应该使用timeBeginPeriod来指示您想要的解决方案。正如您已经发现的那样,在哪里调用它并不重要;可以是主线程,甚至可以是完全不同的应用程序。

请参阅 embarcadero 论坛上的帖子,当然还有MSDN 上的文档(备注)。

If you're using Sleep in your threads (hence my comment/query to your question), you should use timeBeginPeriod to indicate your desired resolution. As you've already found out it doesn't matter where you call it; can be the main thread or even an entirely different application.

See this thread on embarcadero forums, and of course the documentation (remarks) on MSDN.

ぃ弥猫深巷。 2024-09-20 13:15:38

您的操作系统安装在两台不同的 PC 上吗?
我猜你的一台电脑有真正的双核处理器(XP 的那台),另一台(Vista 的那台)有单核处理器。有时,多线程应用程序在真正的多核处理器上运行时会暴露出问题。
Delphi 调试器有时会更改 CPU 关联性,因此它可以在调试器上运行,但不能在调试器外部运行。
另一种检查方法:在 XP 下尝试将软件设置为仅与一个 CPU 关联。
我以前见过。但它可能是别的东西,因为你说你已经在多台电脑上尝试过你的软件。

Are your OS installed on two diverse PC?
I guess one of your computer has a true dual-core processor (the one with XP), and the other (the one with Vista) has a one-core processor. Sometimes multi-threaded app reveals their problem when run on true multi-core processor.
The Delphi debugger sometimes change the CPU affinity, so it could work on the debugger, but not outside it.
Another possibility to check: try your software under XP with setting affinity to only one CPU.
I've seen that before. But it's likely something else, since you said you've tried your SW in multiple PCs.

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