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"?
-
-
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?
-
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.
-
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. -
How about writing some progress to the console?
-
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.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. -
I think he meant if you do a Windows Logout / Shutdown?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.
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...Minh said:
I think he meant if you do a Windows Logout / Shutdown?TommyCarlier said:*snip*
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...
Not in console apps. -
So how come the console programs I write end simply enough by closing their terminal window.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.
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?
Thread Closed
This thread is kinda stale and has been closed but if you'd like to continue the conversation, please create a new thread in our Forums,
or Contact Us and let us know.