如何在后台运行.NET控制台应用程序

如何在后台运行.NET控制台应用程序

问题描述:

我有控制台应用程序写在计划运行,每15分钟C#。左右使用内置的Windows任务计划程序。
每次运行黑色储物箱为它的执行期间弹出,然后关闭。
我不写任何东西到控制台。有没有办法让这个在后台运行?

I have Console Application written in C# that is scheduled to run every 15 min. or so using the Built in Windows Task Scheduler. Every time it runs the black console box pops up for the duration of it's execution and then closes. I am not writing anything to the console. Is there a way to make this run in the background?

轻松!

这似乎很难相信,但可以作为一个魅力。当您希望与任何迹象执行自定义任务,我已经使用了一段安装项目。

It seems hard to believe, but works as a charm. I have used this for some setup projects, when you want to perform custom tasks with no signs of it.


  • 创建项目作为Windows应用程序项目(这是最困难的部分)。

  • 永远不会调用任何形式的,只是恰好保持在您的控制台应用程序

  • Create the project as a Windows application Project (this is the hard part).
  • Never calls to any form, just keep on in exactly as in your console application

class Program
{
    static void Main(string[] args)
    {
        // just dont Application.Run(new frmMain(args));
        //... your code
    }
 }


这是因为Windows应用程序项目比控制台没有真的不同,因为第一种形式和参考节选。
完全隐藏的执行
尝试一下!
HTH

This is because windows application projects are no really different than console, excepts because of the first form and references. Totally hidden execution Try it! HTH