2017-07-24 24 views
2

我想写一个将调用我的已安装应用程序的石英作业。使用石英作业调用应用程序

比如我有控制台应用程序:

class Program 
{ 
    static void Main(string[] args) 
    { 
     Console.WriteLine(Datetime.Now()); 
     Console.ReadLine(); 
    } 
} 

和发布我的Windows机器上这个程序。现在我写这个代码:

class Program 
{ 
    static void Main(string[] args) 
    { 
     var schedFact = new StdSchedulerFactory(); 

     var sched = schedFact.GetScheduler(); 
     sched.Start(); 

     var job = JobBuilder.Create<TestJob>() 
      .WithIdentity("testjob", "testgroup") 
      .Build(); 

     var trigger = TriggerBuilder.Create() 
      .WithIdentity("testtrigger", "testgroup") 
      .WithSimpleSchedule(x => x.WithIntervalInMinutes(1).RepeatForever()) 
      .Build(); 

     sched.ScheduleJob(job, trigger); 
    } 

} 


public class TestJob : IJob 
{ 
    public void Execute(IJobExecutionContext context) 
    { 
     // Here I want to call my app 
    } 
} 

我该怎么做?

+0

使用的Process.Start并添加参数,你的第一个控制台EXE – Paul

回答

1

在你Execute()方法,调用可执行应用程序需要调用:

// eg: "C:/MyApp/app.exe" 
System.Diagnostics.Process.Start("PathToApplication.exe"); 

MSDN Documentation