Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

threading delphi tptimecritical tpnormal problem hanging application freeze setwaitabletimer

Posted on 2004-09-22
8
Medium Priority
?
875 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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

636 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