Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I got simple method with defination defined in a interface. I am trying to call this method from Startup.cs using RecurringJob but getting exception. This is very simple test method.

Interface

 public interface IEziDataLoader
{
    Task TestMe();
}

class

public async Task TestMe()
    {
        Console.WriteLine("Method called from Hangfire");
        
    }

Startup.cs

RecurringJob.AddOrUpdate<IEziDataLoader>($"TestMe", x => x.TestMe());

error

 cannot resolve AddOrUpdate

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
334 views
Welcome To Ask or Share your Answers For Others

1 Answer

found the answer;

RecurringJob.AddOrUpdate("hello", () => Console.WriteLine("hello World"), "* * * * *");

RecurringJob.AddOrUpdate<IDataLoader>("TestMethod", x=>x.TestMe(), "* * * * *");

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...