TDDatATS
asked on
threading delphi tptimecritical tpnormal problem hanging application freeze setwaitabletimer
Hi there,
we wrote a Delphi application using multiple threads. One for scanning an hardware component, another one for communicating over TCP/IP and a last one for critical timing. The last one is a component we designed using the SetWaitableTimer API from windows. This function is encapsulated in a thread. When this thread priority is put to TimeCritical, the application works without any problem. If we put it to tpNormal, the application crashes with a huge network load. When we insert logging in the application, it shows that he hangs on a different line of code each time, so it seems that the code isn't wrong and that the threads are messing up something when it is set to tpNormal. Does anyone has tips, tricks, ideas of how to search this error and trap it..... We are already searching for weeks and we are a little bit out of ideas....
we wrote a Delphi application using multiple threads. One for scanning an hardware component, another one for communicating over TCP/IP and a last one for critical timing. The last one is a component we designed using the SetWaitableTimer API from windows. This function is encapsulated in a thread. When this thread priority is put to TimeCritical, the application works without any problem. If we put it to tpNormal, the application crashes with a huge network load. When we insert logging in the application, it shows that he hangs on a different line of code each time, so it seems that the code isn't wrong and that the threads are messing up something when it is set to tpNormal. Does anyone has tips, tricks, ideas of how to search this error and trap it..... We are already searching for weeks and we are a little bit out of ideas....
I'd do the same thing. But I'd go a step futher and use the QueryPerformanceCounter to give the timestamp, not anything that's based on GetTickCount or even worse, dd/mm/yyyy hh:nn:ss.zzz. Yuck!
Col.
Col.
Also I'd spend some time looking through the entire code to see if there's nothing trying to talk across threads. Even down to the point where all my inter-thread communication is done via the Windows message Queue.
Col.
Col.
Are you using Delphi threads or win32 threads? In the latter case make sure you've set "IsMultiThread := true". Otherwise the memory manager will crash.
Also madExcept might be worth a try. It's free for non-commercial usage. If your project is commercial, you can use the non-commercial version for evaluation:
http://help.madshi.net/madExcept.htm
http://madshi.net/madCollection.exe
Also madExcept might be worth a try. It's free for non-commercial usage. If your project is commercial, you can use the non-commercial version for evaluation:
http://help.madshi.net/madExcept.htm
http://madshi.net/madCollection.exe
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Sorry DanRoillins, Modulo,
I was a little bit busy that period.
Thanks for cleaning up.
Tom.
I was a little bit busy that period.
Thanks for cleaning up.
Tom.
The only way I managed to solve such problems was by using a log file and then write as much as possible information to this log file. Every thread it's own log file and every line with a timestamp.