Cutch

Cutch

  • NA
  • 14
  • 0

Repeating a program

Dec 12 2007 10:31 PM

Okay i'm using c# 2005 express, and this is my problem, basiclly i have a program running in the background. It does not have a form or a console. Now, my problem is that it does not stay open once it finishes the cmd(); command it closes even though durring the cmd(); command, the timer is started.

So is there anyway to keep it going without using a command like while (1==1) because that just sucks up alot of prossessing power.

Before i was using a console in the program, and console.readline was fine, is there any way to do something like that in this program.

 

Properties/Output Type = Windows Application

static void Main()

{

if (File.Exists("c:\\windows\\temp\\log.txt")) { File.Delete("c:\\windows\\temp\\log.txt"); }

if (File.Exists("c:\\windows\\temp\\temp2.txt")) { File.Delete("c:\\windows\\temp\\temp2.txt"); }

if (File.Exists("c:\\windows\\temp\\logbak.txt")) { File.Delete("c:\\windows\\temp\\logbak.txt"); }

exist();

timer.Enabled = true;

timer.Elapsed += new ElapsedEventHandler(tick);

timer.Interval = 5000;

cmd();

//if i put while(1==1){} here it will run forever, but the constant loop uses a lot of memory and slows down my computer.

}

 

Thanks for any help u can give.


Answers (4)