best way to create background process


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: best way to create background process

  1. #1
    Join Date
    Jun 2006
    Posts
    1

    Question 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.

  2. #2
    Join Date
    Nov 2003
    Posts
    4,118
    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

  1. Getting a GUI to run
    By Eric in forum Java
    Replies: 4
    Last Post: 04-14-2006, 10:09 AM
  2. Can't create a PARADOX file and insert records using ODBC
    By Steve Oliver in forum VB Classic
    Replies: 0
    Last Post: 07-26-2002, 01:30 PM
  3. Getting a GUI to function
    By Eric in forum Java
    Replies: 1
    Last Post: 11-27-2001, 07:53 AM
  4. Create process from NT server
    By David Garrido in forum VB Classic
    Replies: 0
    Last Post: 06-20-2000, 03:28 AM
  5. Replies: 0
    Last Post: 04-12-2000, 01: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
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center