我正在使用hangfire版本“1.6.12.0”。它工作正常,但是当发生错误时它停止在预定的工作上工作。
正如我在日志文件中看到的错误是:
消息:线程正在中止。
stack:at System.Threading.Thread.SleepInternal(Int32 millisecondsTimeout) 在System.Threading.Thread.Sleep(Int32 millisecondsTimeout) 在HangfireCronJobs.Controllers.HomeController.Myfunction()
但是当我点击浏览器上的hangfire URL时,会自动启动预定作业。
我的代码如下:
public ActionResult Recurring()
{
RecurringJob.AddOrUpdate(() => JobExicute(), Cron.MinuteInterval(10));
}
public void JobExicute()
{
fun1();
fun2();
fun3();
}
public static void fun1()
{
try
{
string strPath = ConfigurationManager.AppSettings["EXEpath"].ToString();
Process p = new Process();
p.StartInfo.FileName = @"" + strPath + "" + "\\map1.exe";
p.Start();
Thread.Sleep(1000 * 60);
}
catch (Exception ex)
{
Logger.Log("Error Message: " + ex.Message, 0);
Logger.Log("Stack Trace: " + ex.StackTrace, 0);
}
}
public static void fun2()
{
try
{
string strPath = ConfigurationManager.AppSettings["EXEpath"].ToString();
Process p = new Process();
p.StartInfo.FileName = @"" + strPath + "" + "Graph\\map2.exe";
p.Start();
Thread.Sleep(1000 * 60);
}
catch (Exception ex)
{
Logger.Log("Error Message: " + ex.Message, 0);
Logger.Log("Stack Trace: " + ex.StackTrace, 0);
}
}
public static void fun3()
{
try
{
string strPath = ConfigurationManager.AppSettings["EXEpath"].ToString();
Process p = new Process();
p.StartInfo.FileName = @"" + strPath + "" + "Graph\\map3.exe";
p.Start();
Thread.Sleep(1000 * 60);
}
catch (Exception ex)
{
Logger.Log("Error Message: " + ex.Message, 0);
Logger.Log("Stack Trace: " + ex.StackTrace, 0);
}
}