|
-
July 24th, 2008, 04:47 AM
#1
Multithreaded Console application similar to windows Application.
I am creating a multi-threading console application where the primary thread initiates 2 more threads. One reads data on sockets and other logs the data in file.
Now i want that the primary thread should be capable of handling window messages like WM_CLOSE or minimize/maximize. If i am able to capture these messages i can gracefully exit my secondary threads and clean up memory allocated and close all open threads.
I want to know how can i capture the messages in console window program when user clicks on close/minimize/maximize button.
Kavitesh Singh.
-
July 24th, 2008, 05:36 AM
#2
Re: Multithreaded Console application similar to windows Application.
 Originally Posted by kavitesh
Now i want that the primary thread should be capable of handling window messages like WM_CLOSE or minimize/maximize. If i am able to capture these messages i can gracefully exit my secondary threads and clean up memory allocated and close all open threads.
SetConsoleCtrlHandler, signal, and atexit pop to mind.
-
July 24th, 2008, 06:25 AM
#3
Re: Multithreaded Console application similar to windows Application.
Well i tried
atexit()
but then it only works if application reaches normal end.
If application is doing something and i press [x] button it does not execute.
I wanted any kind of termination should be handled and done some clean up operation and then exit.
Kavitesh Singh
-
July 24th, 2008, 06:47 AM
#4
Re: Multithreaded Console application similar to windows Application.
 Originally Posted by kavitesh
I wanted any kind of termination should be handled and done some clean up operation and then exit.
So handle CTRL_CLOSE_EVENT (via SCCH) and whatever else you may need.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|