Solved

threading delphi tptimecritical tpnormal problem hanging application freeze setwaitabletimer

Posted on 2004-09-22
8
853 Views
Last Modified: 2008-01-09
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....
0
Comment
Question by:TDDatATS
8 Comments
 
LVL 17

Expert Comment

by:Wim ten Brink
ID: 12122325
Timing issue in multiple threads. Nasty. Probably an unprotected resource that gets read and written at the same time. I've had similar problems and they're extremely hard to debug.

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.
0
 
LVL 4

Expert Comment

by:Colin_Dawson
ID: 12127026
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.
0
 
LVL 4

Expert Comment

by:Colin_Dawson
ID: 12127050
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.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 20

Expert Comment

by:Madshi
ID: 12130944
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
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 13442893
PAQed with no points refunded (of 250)

modulo
Community Support Moderator
0
 

Author Comment

by:TDDatATS
ID: 13600704
Sorry DanRoillins, Modulo,

I was a little bit busy that period.

Thanks for cleaning up.

Tom.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now