-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathForm1.cs
More file actions
75 lines (69 loc) · 2.39 KB
/
Copy pathForm1.cs
File metadata and controls
75 lines (69 loc) · 2.39 KB
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
71
72
73
74
75
using System;
using System.Threading.Tasks;
using DevExpress.DashboardCommon;
namespace DashboardDesignerAsyncModeExample
{
public partial class Form1 : DevExpress.XtraEditors.XtraForm
{
static object myData;
public Form1()
{
InitializeComponent();
dashboardDesigner1.AsyncMode = true;
dashboardDesigner1.DataSourceOptions.ObjectDataSourceLoadingBehavior = DevExpress.DataAccess.DocumentLoadingBehavior.LoadAsIs;
dashboardDesigner1.DataLoading += DashboardDesigner1_DataLoading;
dashboardDesigner1.AsyncDataLoading += DashboardDesigner1_AsyncDataLoading;
Task.Run(async () => await LoadData());
}
private void DashboardDesigner1_DataLoading(object sender, DataLoadingEventArgs e)
{
if (!dashboardDesigner1.AsyncMode)
e.Data = myData;
}
private void DashboardDesigner1_AsyncDataLoading(object sender, DataLoadingEventArgs e)
{
if (dashboardDesigner1.AsyncMode)
e.Data = myData;
}
private void btnLoadAsync_Click(object sender, EventArgs e)
{
dashboardDesigner1.AsyncMode = true;
lblMode.Text = "ASYNC";
dashboardDesigner1.LoadDashboard("test.xml");
}
private void btnLoadSync_Click(object sender, EventArgs e)
{
dashboardDesigner1.AsyncMode = false;
lblMode.Text = "SYNC";
dashboardDesigner1.LoadDashboard("test.xml");
}
private async void btnReloadData_Click(object sender, EventArgs e)
{
await LoadData();
}
private async Task LoadData()
{
if (dashboardDesigner1.AsyncMode)
await LoadDataAsynchronously();
else
LoadDataSynchronously();
}
private async Task LoadDataAsynchronously()
{
string s = lblMode.Text;
lblMode.Text = "Loading...";
await Task.Run(() => {
myData = SalesData.CreateData();
})
.ContinueWith((t) => {
dashboardDesigner1.ReloadDataAsync();
});
lblMode.Text = s;
}
private void LoadDataSynchronously()
{
myData = SalesData.CreateData();
dashboardDesigner1.ReloadData();
}
}
}