Tech Off Thread

9 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

Tell Windows that my program is responding

Back to Forum: Tech Off
  • User profile image
    ploe

    So I have this c++ console application that takes a while to close. In my SetConsoleCtrlHandler handler I have to write some things to disk before my program can closes. So when you close my application the End Program dialog comes up because Windows thinks my application is not responding. Is there a way for me to tell Windows "hey I am still responding, it just takes me a while to close"?

  • User profile image
    littleguru

    Why are you actually writing that much data while closing? I mean it might be valid to do that but I'm curious why you keep all that stuff to the end. What if your application crashes, do you loose data?

  • User profile image
    TommyCarlier

    Console applications are not meant to be closed by the user. They don't have a message loop and should shut down when their task has been performed.

  • User profile image
    ploe

    TommyCarlier said:
    Console applications are not meant to be closed by the user. They don't have a message loop and should shut down when their task has been performed.

    This console app performs calculations that are particularly expensive. So I cache them in a hash_map. What I am doing is writing the hash_map to disk so that I can repopulate the cache when the app starts up again. I do also save the cache to disk once in a while just in case the app were to crash.

    I guess what I could do is increase the frequency to which I save the cache while the app is running, but I will lose any calculations between when I last saved and when I close the app.

  • User profile image
    staceyw

    How about writing some progress to the console?

  • User profile image
    Curt Nichols

    ploe said:
    TommyCarlier said:
    *snip*

    This console app performs calculations that are particularly expensive. So I cache them in a hash_map. What I am doing is writing the hash_map to disk so that I can repopulate the cache when the app starts up again. I do also save the cache to disk once in a while just in case the app were to crash.

    I guess what I could do is increase the frequency to which I save the cache while the app is running, but I will lose any calculations between when I last saved and when I close the app.

    Have you considered structuring your file so you can simply append each newly completed computation to the end of the file? That might be faster than writing all your data to the file at once.

  • User profile image
    Minh

    TommyCarlier said:
    Console applications are not meant to be closed by the user. They don't have a message loop and should shut down when their task has been performed.
    I think he meant if you do a Windows Logout / Shutdown?

    It gets worse in Vista... Vista won't even wait for your app... (I think)

    There must be a WM_ that you have to respond to though...

  • User profile image
    Curt Nichols

    Minh said:
    TommyCarlier said:
    *snip*
    I think he meant if you do a Windows Logout / Shutdown?

    It gets worse in Vista... Vista won't even wait for your app... (I think)

    There must be a WM_ that you have to respond to though...
    > There must be a WM_ that you have to respond to though...

    Not in console apps.

  • User profile image
    W3bbo

    TommyCarlier said:
    Console applications are not meant to be closed by the user. They don't have a message loop and should shut down when their task has been performed.
    So how come the console programs I write end simply enough by closing their terminal window.

    But if you open Telnet and try to close it whilst it's attempting to forge a connection it won't die until the network timeout has passed.

    How does it do that?

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.