迟发型和VB.NET - Gettings东西,在应用程序启动类配置 [英] Hangfire and VB.NET - Gettings things configured in the Application Startup class

查看:296
本文介绍了迟发型和VB.NET - Gettings东西,在应用程序启动类配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

本周早些时候我碰到斯科特Hanselman的一篇关于ASP.NET中的后台处理跑(的http:/ /www.hanselman.com/blog/HowToRunBackgroundTasksInASPNET.aspx )。我已经写在程序自动点击页面每隔一段时间运行一些任务的过去,但该后台处理的想法是我从来没有想过,和迟发型(的 http://hangfire.io/ )看上去很适合我的后台处理的需求(主要是发送电子邮件)。

Earlier this week I ran across Scott Hanselman's post about background processing in ASP.NET (http://www.hanselman.com/blog/HowToRunBackgroundTasksInASPNET.aspx). I've written routines in the past that automatically hits a page every so often to run some tasks, but this background processing idea is something I never even considered, and Hangfire (http://hangfire.io/) looks perfect for my background processing needs (mainly sending emails).

要获得迟发型去我需要得到它在应用程序启动类启动(通过的NuGet安装后)。该文档提供C#code说我不知道​​如何转换为VB.NET。它看起来像一些拉姆达code,而我通过我的使用LINQ多少有些熟悉,但​​我不能图快这一个。

To get HangFire going (after installing it via NuGet) I need to get it started up in the Application Startup class. The documentation provides C# code that I'm not sure how to convert to VB.NET. It looks like some lambda code, which I'm somewhat familiar with through my use of LINQ, but I can't quick figure this one out.

public void Configure(IAppBuilder app)
{
    app.UseHangfire(config =>
    {
        config.UseSqlServerStorage("<connection string or its name>");
        config.UseServer();
    });
}

这是在那里我开始,这基本上是微乎其微,我知道... ...:)

This is where I'm starting, which is basically next to nothing, I know... :)

Public Sub Configuration(app As IAppBuilder)
     'This is where I know this code should go... 
End Sub

我倒是AP preciate某个方向或解释,这是怎么回事,以及如何为这个端口code到VB.NET。谢谢!

I'd appreciate some direction or explanation as to what's going on here and how to port this code to VB.NET. Thanks!

推荐答案

您应该可以写为:

Public Sub Configure(app As IAppBuilder)
    Dim act = Sub(config As IBootstrapperConfiguration)
                config.UseSqlServerStorage("<...>")
                config.UseServer()
              End Sub

    app.UseHangfire(act)
End Sub

更多关于在VB.Net创建多行lambda表达式,请参阅 MSDN

这篇关于迟发型和VB.NET - Gettings东西,在应用程序启动类配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆