-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathForm1.vb
70 lines (63 loc) · 2.5 KB
/
Form1.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
Imports System
Imports System.Threading.Tasks
Imports DevExpress.DashboardCommon
Namespace DashboardDesignerAsyncModeExample
Partial Public Class Form1
Inherits DevExpress.XtraEditors.XtraForm
Private Shared myData As Object
Public Sub New()
InitializeComponent()
dashboardDesigner1.AsyncMode = True
dashboardDesigner1.DataSourceOptions.ObjectDataSourceLoadingBehavior = DevExpress.DataAccess.DocumentLoadingBehavior.LoadAsIs
AddHandler dashboardDesigner1.DataLoading, AddressOf DashboardDesigner1_DataLoading
AddHandler dashboardDesigner1.AsyncDataLoading, AddressOf DashboardDesigner1_AsyncDataLoading
Task.Run(Async Function()
Await LoadData()
End Function)
End Sub
Private Sub DashboardDesigner1_DataLoading(ByVal sender As Object, ByVal e As DataLoadingEventArgs)
If Not dashboardDesigner1.AsyncMode Then
e.Data = myData
End If
End Sub
Private Sub DashboardDesigner1_AsyncDataLoading(ByVal sender As Object, ByVal e As DataLoadingEventArgs)
If dashboardDesigner1.AsyncMode Then
e.Data = myData
End If
End Sub
Private Sub btnLoadAsync_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnLoadAsync.Click
dashboardDesigner1.AsyncMode = True
lblMode.Text = "ASYNC"
dashboardDesigner1.LoadDashboard("test.xml")
End Sub
Private Sub btnLoadSync_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnLoadSync.Click
dashboardDesigner1.AsyncMode = False
lblMode.Text = "SYNC"
dashboardDesigner1.LoadDashboard("test.xml")
End Sub
Private Async Sub btnReloadData_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnReloadData.Click
Await LoadData()
End Sub
Private Async Function LoadData() As Task
If dashboardDesigner1.AsyncMode Then
Await LoadDataAsynchronously()
Else
LoadDataSynchronously()
End If
End Function
Private Async Function LoadDataAsynchronously() As Task
Dim s As String = lblMode.Text
lblMode.Text = "Loading..."
Await Task.Run(Sub()
myData = SalesData.CreateData()
End Sub).ContinueWith(Sub(t)
dashboardDesigner1.ReloadDataAsync()
End Sub)
lblMode.Text = s
End Function
Private Sub LoadDataSynchronously()
myData = SalesData.CreateData()
dashboardDesigner1.ReloadData()
End Sub
End Class
End Namespace