blah blah blah is here! blah blah » Close

up0down
link

Hi,
The continuing saga of the Auto Test Rig. It appears that the program runs and will occasionally lock up. Bearing in mind the comms routines I am being made to use are designed to be uninteruptable I think some of the back ground tasks that windows needs to do are being held back until one appears that is higher priorty this then takes over and all the little tasks get executed at the same time. Will an Application.DoEvents() get around this if I put them in liberally or would this cause problems elsewhere ?

Glenn

last answered one year ago

1 answers

up0down
link

Application.DoEvents() only helps if you have a long running task on the UI thread itself. It then enables you to interrupt the task and see whether there are any events in the message queue (such as a button click) which need to be handled, thereby keeping your UI responsive.

It won't help at all if you have long running tasks on background threads. If that's the case and you're getting occasional lock ups, then you may have a deadlock somewhere between your threads when attempting to access 'shared' state or resources. This happens when two (or more) threads are waiting for each other to release a lock and so none of them is able to proceed.

GlennP
329

Okay, could one of these dead lock states cause Windows to fall over and reboot the PC? As this has happened several times when I ran the Exe (it's working! no it isn't!).

vulpes
17279

No, I don't think so. A deadlock could cause a program to hang but it shouldn't cause the machine to reboot itself. If you're only getting these random reboots when running this particular program then, given that you're doing comms, the lost likely cause is a hardware or device driver problem. If you've installed anything new, I'd check on google or with the vendor whether any similar problems have been reported.

GlennP
329

Okay problem has vanished today. Is there an online source for some information on Threading you can recommend?

vulpes
17279

Yes, I'd recommend http://www.albahari.com/threading/ which is a sample chapter from a book and a great overall reference on .NET threading.

Feedback