C#控制台应用程序-使其运行 [英] C# Console Application - Keep it running

查看:94
本文介绍了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.

这篇关于C#控制台应用程序-使其运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆