CadyIO / hangfire-ravendb

RavenDB job storage for Hangfire
https://www.nuget.org/packages/Hangfire.Raven/
18 stars 35 forks source link

Cannot pass a method to BackgroundJob.Enqueue unless it is wrapped in a class local method #14

Closed AustinWinstanley closed 7 years ago

AustinWinstanley commented 7 years ago

Doesn't work:

BackgroundJob.Enqueue(() => System.Console.WriteLine("Background Job: Hello, world!"));

Works:

BackgroundJob.Enqueue(() => Test());

[AutomaticRetry(Attempts = 2, LogEvents = true, OnAttemptsExceeded = AttemptsExceededAction.Delete)]
public static void Test()
{
    Console.WriteLine("Background Job: Hello, world!"));
}
mjohnson0580 commented 7 years ago

I have submitted a pull request #16 that will allow this type of method invocation again (allow calling of methods from other assemblies).

Also fixes an error when calling overloaded methods (e.g. Console.WriteLine) due to parameter types not being handled in the Job serialization/deserialization. I have reverted the code back to using InvocationData when serializing Jobs as this functionality and others is already implemented in the InvocationData class.

AustinWinstanley commented 7 years ago

Good fix @mjohnson0580

Merged and released in 2.1.1