6

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.

Gargoyle
  • 9,590
  • 16
  • 80
  • 145
  • How would one test this (I know a bit about SSIS but don't have enough background to understand the end goal of a having an async Execute Script Task)? – billinkc Apr 06 '19 at 18:07

1 Answers1

10

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.

Ferdipux
  • 5,116
  • 1
  • 19
  • 33
  • The HttpClient method only has an async version of Post :( – Gargoyle Apr 10 '19 at 18:47
  • 1
    I am a late comer to async and await mostly due to coming from a database side and then SSIS and then script tasks. But now that I know about it, it is infuriating to not have that tool inside SSIS. Why the hell would the foreach file not be able to be run async!!!! 1 file at a time... really!!!!!!!! – KeithL Jul 15 '20 at 16:40