SSIS 作业可以异步吗? [英] Can SSIS jobs be async?

查看:26
本文介绍了SSIS 作业可以异步吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 async 方法是否与 SSIS 作业一起正常工作感到有些困惑.脚本任务项创建了一个面向 .NET Framework 4.5 的 Visual Studio 项目,输出类型为类库.

I'm a bit confused on whether the async methods work properly with an SSIS job or not. The Script Task items create a visual studio project that targets .NET Framework 4.5, with an output type of Class Library.

如果我使 main 方法 public async void Main() 并在其中对 async 方法进行 await 调用,它是否真的在等待?

If I make the main method public async void Main() and inside it do await calls against async methods, is it really waiting?

我在这里看到的一些帖子暗示有,而其他帖子暗示没有.

Some of the posts I've seen here imply it does, and others imply it does not.

推荐答案

不幸的是,SSIS 框架和基础 .Net 类早在 4.5 框架及其异步执行模型之前就已创建.您必须按照声明的方式实现 SSIS 方法;声明是经典的而不是异步的.
当我需要在 SSIS 脚本或自定义组件中调用一些异步方法时,我会像这样使用 Task.Run 包装器

Unfortunately, SSIS Framework and base .Net classes were created well before advance of 4.5 Framework and its async execution model. You have to implement SSIS methods as they are declared; the declaration is classic and not async.
When I need to call some async methdos inside SSIS scripts or custom components, I do in with Task.Run wrapper like this

mRes=Task.Run(async () =>
    await AsyncMethod(...).ConfigureAwait(false)).Result;  

也许这不是最好的方法,但它允许在线程池上运行 AsyncMethod.
您从 SSIS 中的 async 调用中获益很少,因为 SSIS 框架本身不是异步就绪.

Perhaps this is not the best approach, but it allows to run AsyncMethod on a ThreadPool.
You benefit little from async calls in SSIS, since SSIS framework is not async-ready itself.

这篇关于SSIS 作业可以异步吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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