问题
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