?
Solved

threading delphi tptimecritical tpnormal problem hanging application freeze setwaitabletimer

Posted on 2004-09-22
8
Medium Priority
?
873 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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 does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

765 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