C# 停止工作
我使用的是hangfire版本“1.6.12.0”。它工作正常,但发生错误时,它将停止对计划作业的工作 正如我在日志文件中看到的,错误是: 消息:线程被中止。C# 停止工作,c#,asp.net-mvc,hangfire,C#,Asp.net Mvc,Hangfire,我使用的是hangfire版本“1.6.12.0”。它工作正常,但发生错误时,它将停止对计划作业的工作 正如我在日志文件中看到的,错误是: 消息:线程被中止。 堆栈:位于System.Threading.Thread.SleepInternal(Int32毫秒) 在System.Threading.Thread.Sleep时(Int32毫秒) 在FirecronJobs.Controllers.HomeController.Myfunction()上 但当我点击浏览器上的HangfireURL时
堆栈:位于System.Threading.Thread.SleepInternal(Int32毫秒) 在System.Threading.Thread.Sleep时(Int32毫秒) 在FirecronJobs.Controllers.HomeController.Myfunction()上 但当我点击浏览器上的HangfireURL时,计划的作业会自动启动 我的代码如下:
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);
}
}
我们怎么知道你只有这条消息?我是通过日志文件得到这条错误消息的。在此消息之后,日志文件不会更新。当作业停止工作时,如何重新启动它。@RahmanyUsama,你能发布定义hangfire作业的代码吗?我已经更新了我的代码,请参阅。