CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2003
    Buenos Aires, Argentina

    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 !!

  2. #2
    Join Date
    Jul 2000
    Milano, Italy
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.