views:

194

answers:

2

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  A: 

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.

A.Bouchez
+4  A: 

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.

Sertac Akyuz
Hello sorry for taking my time in replying, was a public holiday yesterday.This solved it. Upon initialization i just said timePeriodBegin(1) and it runs on all my os's.I'm slightly concerned as to if I should even be using sleep. But as they say, if it works, don't fix it.Thanks again
larry lakeshore
@larry - You're welcome! and don't forget the 'timeEndPeriod'. :)
Sertac Akyuz