我有一个 Web 应用程序,它具有 Page1.aspx,它执行 task1,然后以 fireAndforget 方式将 task2 排入调度程序。
我正在使用 Hangfire,一切都已安装并正常工作,但只有一次doLongJob()
没有参数(测试时)。然后我添加了一个参数(我将添加更多)。之后我面临这些错误
Page1.aspx.cs
string strMsgID = //task1 returns a value;
BackgroundJob.Enqueue(() => doLongJob(strMsgID));
public void doLongJob(string strMsgID)
{
int status = //task2(strMsgID);
while( status == 2)
{
Thread.Sleep(10000);
status = //task2(strMsgID);
}
}
}
启动.cs
using Hangfire;
using Microsoft.Owin;
using Owin;
[assembly: OwinStartup(typeof(erp.Startup))]
namespace erp
{
public class Startup
{
public void Configuration(IAppBuilder app)
{
app.UseHangfireDashboard();
app.UseHangfireServer();
}
}
}
全球.asax.cs
protected void Application_Start(object sender, EventArgs e)
{
GlobalConfiguration.Configuration.UseStorage(new MySqlStorage("hangfire"));
}