每天在一个时间点触发特定的功能或方法

时间:2017-07-13 10:26:04

标签: c# winforms

我有一个应用程序当然有很多方法..以前我使用Windows任务调度程序在预定的时间运行应用程序。现在,我有一个要求,我必须只触发一个特定的方法来完成工作。该方法将在指定的时间点每天运行。 请帮帮我..

P.S:该方法包含在作业完成后删除和存档某些文件夹的代码。因此,没有与SQL的链接,也无法使用SQL Job Scheduler。

2 个答案:

答案 0 :(得分:0)

您可以从任务计划程序将命令行参数传递给您的应用程序。根据命令行参数,您可以调用应用程序中的任何特定方法。

enter image description here

答案 1 :(得分:0)

You could set the command line arguments in the application. Then you can check the value of the command line arguments and then call the appropriate function in the code.

You could do something similar to below :

static void Main(string[] args)
        {
            if (args[0] == "arg1")
            {

            }
            else if (args[0] == "arg2")
            {

            }
         }

你可以只使用调度方法,但是使用不同的参数安排应用程序两次,基于此,你可以根据条件触发你想要的特定功能。

希望它有所帮助...... 如果您对此有任何疑问,请告诉我......