asked on
Function Global_Table_Query([b]ByVal test As Predicate(Of ds2.JOINEDDATADataTable[/b])) As DataTable
ErrorMessage = ""
Dim dt As New DataTable
Dim Is_Good As Byte = 1
Dim thread As New Task(
Function()
Try
Dim lowNums = From row In Global_Table
[b]Where test
[/b] Select row
dt = lowNums.CopyToDataTable
Return dt
Catch ex As Exception
ErrorMessage = ex.Message
Return Nothing
Finally
End Try
End Function
)
Dim tasks() = {thread}
Array.ForEach(tasks, Sub(tx) tx.Start())
Task.WaitAll(tasks)
For Each tsk In tasks
Select Case True
Case tsk.IsCanceled
Is_Good = 1
Case tsk.IsFaulted
Is_Good = 1
Case tsk.IsCompleted
Is_Good = 0
Case Else
Is_Good = 1
End Select
Next
tasks = Nothing
thread = Nothing
'checking if something went wrong
If ErrorMessage <> "" Then
Is_Good = Nothing
Return Nothing
End If
Return dt
End Function