November 20th, 2003, 08:54 AM
Suggestions with printer problem
Hi again !
Generally, my printer turns to a "no-action" status when it cannot print. In such a state, anything regarding that printer hangs... even every printer dissapears from Start-->Settings-->Printer (I'm using Win98).
The problem is that I'm develping an application that, apart from many other things, gets information about printers constantly (just like Printer.ColorMode), and when the printer hangs, the application also does (for example, when requesting Printer.ColorMode).
How could I do to determine if the call to an instruction does not respond within a certain interval of time, to do another thing (like ending the application)? Or any other solution?
Thank you !!
November 20th, 2003, 09:43 AM
Try this way:
(Note: I did not tried myself, cannot swear this is a good
solution, but it is worth a try)
Put code that could hang in a separate application (say activeX
exe) under a timer event
From your first application, you call a method of that activeX that
simply enable the timer.
In the activeX, you can RaiseEvents each time you get info on
printer inside the timer event (last instruction of it)
In your first proigram you can receive the event. If you don't after
a reasonable amount of time (say double the time of the timer
interval, which should be, in any case, over 5 seconds), you could
guess code is about to hang, and could try closing the ActiveX.
If activeX is hanged, you may not be able to stop it, but at least
your first program should not crash as long as you do not try to
call same ActiveX instance again...
...at present time, using mainly Net 4.0, Vs 2010
Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
Click Here to Expand Forum to Full Width
This is a Codeguru.com survey!