我刚刚开始尝试使用Hangfire。 我已经成功安装但是我在创建第一份工作时遇到了困难。
Hangfire.BackgroundJob.Enqueue(Function() Console.WriteLine("Fire-and-forget"))这不会编译:
重载决策失败,因为无法使用以下参数调用可访问的'Enqueue':'公共共享重载函数入队(T)(methodCall As Expression(Of Action(Of T)))As String':类型参数'T'不能推断。 '公共共享重载函数入队(T)(methodCall作为表达式(Of Func(Of T,Task)))As String':无法推断类型参数'T'。
任何想法如何解决? 谢谢
I've just started to try and use Hangfire. I've installed successfully but I'm having difficulty creating the first job.
Hangfire.BackgroundJob.Enqueue(Function() Console.WriteLine("Fire-and-forget"))This won't compile:
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.
Any ideas how to fix? Thanks
最满意答案
Console.WriteLine方法不返回任何内容。 只需将Function关键字替换为Sub即可获取工作表达式树:
BackgroundJob.Enqueue(Sub() Console.WriteLine("Fire-and-forget"))The Console.WriteLine method doesn't return anything. Just replace Function keyword with Sub to get a working expression tree:
BackgroundJob.Enqueue(Sub() Console.WriteLine("Fire-and-forget"))更多推荐
发布评论