如何不断在后台运行一个C#控制台应用程序 [英] how to continuously run a c# console application in background

查看:1363
本文介绍了如何不断在后台运行一个C#控制台应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何在后台运行C#程序中每五分钟为增量。下面的代码是不是我想什么作为后台进程运行,但想找出最佳可能的方法来做到这一点使用此代码,这样我可以实现它的另一个代码。所以这个过程要五分钟后的增量运行。我知道我可以使用线程这样做,但是真正现在如何实现此不。我知道这是最好的方法的如何运行在系统启动时的控制台应用程序,没有出现它显示(后台进程)?这在后台运行,但我怎么会有五分钟的增量运行代码

 类节目
{
静态无效的主要(字串[] args)
{
控制台.WRITE(hellow世界);
到Console.ReadLine();
}
}


解决方案

为什么不只是使用 Windows任务计划程序



将其设置为以所需时间间隔运行你的应用程序。它非常适合这类工作,你不必招惹强迫线程睡觉,可以创造更多的问题,它解决了。


I would like to know how to run a c# program in background every five minute increments. The code below is not what I would like to run as a background process but would like to find out the best possible method to do this using this code so that I can implement it on another code. so this process should run after a five minute increment. I know I could use threads to do so, but dont really now how to implement this. I know this is the best way How to run a console application on system Startup , without appearing it on display(background process)? this to run in the background, but how would I have the code running in five minute increments

 class Program
    {
        static void Main(string[] args)
        {
            Console.Write("hellow world");
            Console.ReadLine();
        }
    }

解决方案

Why not just use Windows Task Scheduler?

Set it to run your app at the desired interval. It's perfect for this sort of job and you don't have to mess about with forcing threads to sleep which can create more problems that it solves.

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

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