Application hangs after period of time

InertiaM

Well-known member
Joined
Nov 3, 2007
Messages
663
Location
Kent, UK
Programming Experience
10+
I deployed an application on a PC recently, and it 'hangs' after a period of time. Summary of the application is as follows :-

Application has a single form. The form has a ToolStrip and nothing else. All the drawing on the form is done using GDI in the Paint event.

It is also running Serial communications, which upon receipt of data from a serial barcode reader, adds the barcode to be processed to a queue. A separate thread processes the queue.

There are also threads for incoming TCP data (from another barcode reader), a thread for processing, and a thread for TCP sending.

The problem is that after say 10 barcodes, the application just hangs. White screen, hourglass, nothing else. The application is littered with loads of Try..Catch blocks which dont seem to be finding the issue. UnhandledException is also included, and this fires for certain problems, but not for the hanging issue.

It's not a problem with one specific barcode, as it will quite happily run all the barcodes I send it at different times. It seems to relate more to the 'quantity' of barcodes.

The only way of closing the application is using Task Manager, which is not closing the Serial or TCP threads properly, and therefore the application cannot be run again until the PC is logged off and back on again.

Really frustrating me :confused: :( any suggestions gratefully received.
 
Add some tracing to your app. You can then look at the log file afterwards and see exactly what your app was doing the whole time. The more tracing you do, the more fine-grained the picture of your app's activity it will present and the easier it will be to pinpoint the exact location of the issue. You might want to start with fairly course tracing and see if you can narrow down the area a bit, then add finer-grained tracing to just that area to narrow it down further. You can keep doing that to smaller and smaller areas until you have the exact location.

Note that a hang is not the result of an exception, or at least not directly. An application hanging will normally occur for one of two reasons:

1. A synchronous method that never returns.
2. An infinite loop.

That's where you should focus your search.
 
Thanks jmc. Already have the coarse tracing in, but am frantically adding more fine.

Agreed on the principle of exception doesnt make it hang. I was trying to show that, AFAIK, it isnt a result of an exception as the UnhandledException code is in and working.

One other point (forgot this originally, sorry). When I go to Task Manager to close it, there are two tasks showing for my application, but when it is running normally, there is only one. Cant 'switch to' either task.
 
Back
Top