Click to See Complete Forum and Search --> : Multithreaded Console application similar to windows Application.


kavitesh
July 24th, 2008, 04:47 AM
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.

Plasmator
July 24th, 2008, 05:36 AM
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.

kavitesh
July 24th, 2008, 06:25 AM
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.

Plasmator
July 24th, 2008, 06:47 AM
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.