-
best way to create background process
hello all. first time poster and relatively new to serious c/c++ programming. I'm looking for the best way to accomplish the following:
I have to create a background process that will periodically check some system settings. one key is that the app has to respond to a windows logoff/shutdown message from the OS so that it can do some final work (especially kill the timer that it set up).
because the app has to remain responsive to this endsession message, using a call to Sleep() won't work, as the program is unresponsive during said call.
i have chosen to set and use timers, but i don't know how to start a windowless (ie no GUI) program that will load up and then just sit there (after registering a timer that will call back to the program at a prescribed interval).
if i try this (pseudocode for brevity):
Code:
main() {
timer = setTimer(NULL,(int)NULL,60000,TIMERPROC(&timerFx));
}
i don't know how to have this program just sit idle without the main function exiting the app terminating.
is there a way to create a non-GUI app that will load and then just keep running but doing nothing until the timer fires? this app is supposed to be as small and fast as possible, so i'm trying to eliminate the GUI if i can, since it will never be shown anyway.
thank you for any input.
-
What you need is a service. Services run in the background, they are awoken by events, and in the rest of the time they are idle. You can write a full blown service but any console app that waits for a specific event will do. Obviously, you don't need GUI here since the process runs in the background. Read about timers and event handlers. That's the core of this process.
Danny Kalev
Similar Threads
-
Replies: 4
Last Post: 04-14-2006, 09:09 AM
-
By Steve Oliver in forum VB Classic
Replies: 0
Last Post: 07-26-2002, 12:30 PM
-
Replies: 1
Last Post: 11-27-2001, 07:53 AM
-
By David Garrido in forum VB Classic
Replies: 0
Last Post: 06-20-2000, 02:28 AM
-
By John Harkin in forum Enterprise
Replies: 0
Last Post: 04-12-2000, 12:05 PM
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
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|