Running my program in the background

This is a discussion on Running my program in the background within the Windows Programming forums, part of the Platform Specific Boards category; ive searched the forum and not found something like what i was looking for. most of the similar topics have ...

  1. #1
    Registered User
    Join Date
    Jun 2005
    Posts
    108

    Running my program in the background

    ive searched the forum and not found something like what i was looking for. most of the similar topics have been ended through suspicion of potential malware usage (which is fair enough).

    ive now completed a program to process some data from a COM port and when i run it, it is using too much processor power. its a MS-DOS program run in the windows environment, which is extracting real time info from a com port.

    i want to push this program into the background so it runs silently and preferably with a small icon in the taskbar. hopefully, this will reduce processor power, am i right? if not, then i wont bother but if it will, can someone point me in the right direction?

    thanks

  2. #2
    cwr
    cwr is offline
    Registered Luser cwr's Avatar
    Join Date
    Jul 2005
    Location
    Sydney, Australia
    Posts
    869
    I'm not familiar with Windows multi-tasking, it might be brain damaged, but most operating systems will give a program all the available CPU time it requests. That is, regardless of whether something is "running in the background" or not, a for ( ; ; ) ; infinite loop (for example) will thrash all free CPU time. This won't necessarily mean that other programs will be less responsive, because the operating system will preempt the process and force a context switch.

    On the other hand, if a program that is IO bound (like your COM port example should be), the process will block while waiting for data from this port, and the operating system will decide not to waste time and give the CPU over to another process. Either way, "backgrounding" won't have much effect.

    As for how to do this, it really has nothing to do with the C language, because it's a platform specific feature. This thread should probably be moved to "Windows Programming"
    Last edited by cwr; 10-07-2005 at 07:52 AM. Reason: emoticon interpolation caused my for loop to go happy.

  3. #3
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    The easiest way is to make it a GUI program, and if you don't make any window in your GUI program, it is just like it runs in the background.

  4. #4
    Registered User
    Join Date
    Jun 2005
    Posts
    108
    thanks alot guys

  5. #5
    The N00b That Owns You!
    Join Date
    Jul 2005
    Location
    Canada!
    Posts
    178
    try this tutorial it should vcover this and future questions: http://code.glowdot.com/tutorials/win32tutorial.php
    New Function!!!!

    glAddIdol(C+noob);

    The feeling of rusty spoons against my salad fingers is almost ORGASMIC

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Program Plan
    By Programmer_P in forum C++ Programming
    Replies: 0
    Last Post: 05-11-2009, 02:42 AM
  2. How to tell when internal program is done running
    By PJYelton in forum Windows Programming
    Replies: 5
    Last Post: 03-21-2005, 10:09 PM
  3. Running my program.....estimated to take 55 hrs...
    By AssistMe in forum C Programming
    Replies: 14
    Last Post: 03-21-2005, 12:46 AM
  4. fopen();
    By GanglyLamb in forum C Programming
    Replies: 8
    Last Post: 11-03-2002, 12:39 PM
  5. Running program on background?
    By Couhilin in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 11-03-2001, 07:50 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21