I have a web application which has Page1.aspx that does task1 and then enqueue task2 to scheduler in fireAndforget manner.
I am using Hangfire and everything is installed and worked correctly but only once when doLongJob() had no parameters (while testing). Then I added a parameter (and I will be adding more). After that I am facing these errors.
Can not find the target method. The type ‘’ does not contain a method with signature doLongJob(String)
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);
}
}
Startup.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();
}
}
}
Global.asax.cs
protected void Application_Start(object sender, EventArgs e)
{
GlobalConfiguration.Configuration.UseStorage(new MySqlStorage("hangfire"));
}