Hangfire.BackgroundJob.Enqueue使用VB(Hangfire.BackgroundJob.Enqueue Using VB)

系统教程 行业动态 更新时间:2024-06-14 17:04:02
Hangfire.BackgroundJob.Enqueue使用VB(Hangfire.BackgroundJob.Enqueue Using VB)

我刚刚开始尝试使用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"))

更多推荐

本文发布于:2023-04-24 20:54:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/0b32768be63fbdac7fd0e5ce30cd46dd.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:BackgroundJob   Hangfire   VB   Enqueue

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!