Click here to Skip to main content
15,888,027 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Page1.aspx.cs

C#
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

C#
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

C#
protected void Application_Start(object sender, EventArgs e)
{
    GlobalConfiguration.Configuration.UseStorage(new MySqlStorage("hangfire"));
}


What I have tried:

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.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900