Delphi multithreaded application built in vista and won't run in XP

邮差的信 提交于 2019-12-07 12:41:01

问题


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


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/3435083/delphi-multithreaded-application-built-in-vista-and-wont-run-in-xp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!