Hangfire.BackgroundJob.Enqueue 使用 VB
Hangfire.BackgroundJob.Enqueue Using VB
我刚刚开始尝试使用 Hangfire。我已成功安装,但创建第一份工作时遇到困难。
Hangfire.BackgroundJob.Enqueue(Function() Console.WriteLine("Fire-and-forget"))
这不会编译:
Overload resolution failed because no accessible 'Enqueue' can be
called with these arguments:
'Public Shared Overloads Function Enqueue(Of T)(methodCall As Expression(Of Action(Of T))) As String': Type parameter 'T' cannot be
inferred.
'Public Shared Overloads Function Enqueue(Of T)(methodCall As Expression(Of Func(Of T, Task))) As String': Type parameter 'T' cannot
be inferred.
有什么解决办法吗?
谢谢
Console.WriteLine
方法没有 return 任何东西。只需将 Function
关键字替换为 Sub
即可获得工作表达式树:
BackgroundJob.Enqueue(Sub() Console.WriteLine("Fire-and-forget"))
我刚刚开始尝试使用 Hangfire。我已成功安装,但创建第一份工作时遇到困难。
Hangfire.BackgroundJob.Enqueue(Function() Console.WriteLine("Fire-and-forget"))
这不会编译:
Overload resolution failed because no accessible 'Enqueue' can be called with these arguments: 'Public Shared Overloads Function Enqueue(Of T)(methodCall As Expression(Of Action(Of T))) As String': Type parameter 'T' cannot be inferred. 'Public Shared Overloads Function Enqueue(Of T)(methodCall As Expression(Of Func(Of T, Task))) As String': Type parameter 'T' cannot be inferred.
有什么解决办法吗? 谢谢
Console.WriteLine
方法没有 return 任何东西。只需将 Function
关键字替换为 Sub
即可获得工作表达式树:
BackgroundJob.Enqueue(Sub() Console.WriteLine("Fire-and-forget"))