Dim task2 = task1.ContinueWith(Function(t) Return BulkCopyToTableAsync(tableName, dt) End Function, TaskContinuationOptions.OnlyOnRanToCompletion).Unwrap()
'TaskContinuationOptions.OnlyOnOnlyOnFaultedでエラー?。 Dim task3 = task1.ContinueWith(Sub(t) MessageBox.Show(t.Exception.Message), CancellationToken.None, TaskContinuationOptions.OnlyOnOnlyOnFaulted, TaskScheduler.FromCurrentSynchronizationContext()) Dim task4 = task2.ContinueWith(Sub(t) MessageBox.Show(t.Exception.Message), CancellationToken.None, TaskContinuationOptions.OnlyOnOnlyOnFaulted, TaskScheduler.FromCurrentSynchronizationContext())
Private Async Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Button1.Enabled = False Loading.Visible = False 'gif表示 Dim dt As DataTable = '対象のファイルを読み込みDataTable型で渡す。 If dt Is Nothing Then Exit Sub End If Await UpdateTableAsync("TableName", dt) Button1.Enabled = True LoadingAnime.Visible = False End Sub