MicroSoftの解説に、次のようなものがあります。
「継続タスクを使用したタスクの連結」
https://learn.microsoft.com/ja-jp/dotnet/standard/parallel-programming/chaining-tasks-by-using-continuation-tasks
この中に、次のようなコードの記載があり、taskA.ContinueWith(Sub(antecedent)の部分で、ラムダ式にantecedentという引数が渡されています。
しかし、Main()の中に、antecedentという変数は宣言されていません。
どこから?発生したのでしょうか?
Imports System.Threading.Tasks
Module Example
Public Sub Main()
Dim taskA As Task(Of DayOfWeek) = Task.Run(Function() DateTime.Today.DayOfWeek)
Dim continuation As Task = taskA.ContinueWith(Sub(antecedent)
Console.WriteLine("Today is {0}.", antecedent.Result)
End Sub)
continuation.Wait()
End Sub
End Module
VisalStudioにコピペして、「antecedent」の部分にカーソルを当てると、antecedent As Task(Of DayOfWeek)となっており、
taskAを指しているようです。
メソッドチェンの親を指すのでしょうか?
詳しい方、宜しくお願い致します。