-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathAsyncChildNodesSelector.vb
48 lines (39 loc) · 1.75 KB
/
AsyncChildNodesSelector.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
Imports DevExpress.Xpf.Grid
Imports System
Imports System.Collections
Imports System.Threading
Imports System.Threading.Tasks
Namespace AsyncChildNodesSelector
Public Class CustomChildrenSelector
Implements IAsyncChildNodesSelector
Public Function HasChildNode(ByVal item As Object, ByVal token As CancellationToken) As Task(Of Boolean) Implements IAsyncChildNodesSelector.HasChildNode
Return Task.Run(Async Function()
For i As Integer = 0 To 10 - 1
token.ThrowIfCancellationRequested()
Await Task.Delay(25)
Next
Return Not(TypeOf item Is StageTask)
End Function)
End Function
Public Function SelectChildren(ByVal item As Object) As IEnumerable Implements IChildNodesSelector.SelectChildren
Throw New NotImplementedException()
End Function
Public Function SelectChildrenAsync(ByVal item As Object, ByVal token As CancellationToken) As Task(Of IEnumerable) Implements IAsyncChildNodesSelector.SelectChildrenAsync
Return Task.Run(Async Function()
For i As Integer = 0 To 10 - 1
token.ThrowIfCancellationRequested()
Await Task.Delay(100)
Next
Return SelectChildNodes(item)
End Function)
End Function
Public Function SelectChildNodes(ByVal item As Object) As IEnumerable
If TypeOf item Is ProjectStage Then
Return TryCast(item, ProjectStage).Tasks
ElseIf TypeOf item Is ProjectObject Then
Return TryCast(item, ProjectObject).Stages
End If
Return Nothing
End Function
End Class
End Namespace