Solved

threading delphi tptimecritical tpnormal problem hanging application freeze setwaitabletimer

Posted on 2004-09-22
8
868 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

713 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