C#控制台应用程序-使其运行

C#控制台应用程序-使其运行

问题描述:

我将要开发一个控制台应用程序,它将需要在特定时间连续运行和执行工作。

I am about to develop a console application that will be required to continually run and carry out work at specific times.

我的问题是最好的方法是什么?

My question is what is are best methods or practices to keep your application alive?

我的想法是:
永无止境的循环?
一个计时器,该计时器会休眠,然后在需要时(设置了休眠时间后)跳至例行程序?

My thought were: A loop that never ends? A timer that sleeps and then jumps to routine when required (after set sleep period)?

我将应用程序编译为exe,然后使用AlwaysUp将其作为服务运行。

I will be compiling the application into an exe and then running it as a service using AlwaysUp.

..

Peter

一个更好的解决方案是编写完成其工作并退出的控制台应用程序。然后,您可以使用Windows Task Scheduler定期运行它。

A better solution would be to write a console application that does its job and quits. You can then use the Windows Task Scheduler to run it periodically.