Can SSIS jobs be async?

无人久伴 提交于 2020-08-08 02:08:22

问题


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.

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.


回答1:


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;  

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.



来源:https://stackoverflow.com/questions/55540754/can-ssis-jobs-be-async

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!