Solved

threading delphi tptimecritical tpnormal problem hanging application freeze setwaitabletimer

Posted on 2004-09-22
8
862 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
Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 
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

ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi Mdi application Child forms get behind control 7 211
Strange behavior when a form is closed 6 57
tidtcpserver connection lost handle 2 83
Performance of SQL statement 37 111
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
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 Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

770 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