DashboardControl.UpdateExtractDataSourcesAsync(Action<String, ExtractUpdateResult>, Action<String, ExtractUpdateResult>) Method
Updates all extract data sources in the current dashboard asynchronously. Allows you to specify custom actions to perform after updating the data and file.
Namespace: DevExpress.DashboardWpf
Assembly: DevExpress.Dashboard.v24.1.Wpf.dll
NuGet Package: DevExpress.Wpf.Dashboard
Declaration
public Task UpdateExtractDataSourcesAsync(
Action<string, ExtractUpdateResult> onDataUpdated,
Action<string, ExtractUpdateResult> onFileUpdated
)
Parameters
Name | Type | Description |
---|---|---|
onDataUpdated | Action<String, ExtractUpdateResult> | A custom action to perform when the data is updated. |
onFileUpdated | Action<String, ExtractUpdateResult> | A custom action to perform when the file is updated. |
Returns
Type | Description |
---|---|
Task | The task object that is the asynchronous operation to complete. |
Example
The following code snippet implements the UpdateExtractAsync method that updates all extract files bound to the dashboard. It displays a message box and reloads DashboardViewer’s data when data is updated, and displays a message box when the extract files are updated.
using System.Windows;
namespace UpdateExtractDataSourceExample
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : DevExpress.Xpf.Core.ThemedWindow
{
delegate void SafeUpdate(string file);
public MainWindow() {
InitializeComponent();
dashboardControl1.LoadDashboard("update_data_extract_dashboard.xml");
}
private async void Button_Click(object sender, RoutedEventArgs e) {
await dashboardControl1.UpdateExtractDataSourcesAsync(
(fileName, result) => { OnDataReady(fileName); },
(fileName, result) => { MessageBox.Show($"File {fileName} updated "); });
}
void OnDataReady(string fileName)
{
dashboardControl1.Dispatcher.Invoke(new SafeUpdate(UpdateViewer), new object[] { fileName });
}
void UpdateViewer(string fileName)
{
MessageBox.Show($"Data for the file {fileName} is ready ");
dashboardControl1.ReloadData();
}
}
}
<dx:ThemedWindow x:Class="UpdateExtractDataSourceExample.MainWindow" mc:Ignorable="d" Title="Update ExtractDataSource" Height="500" Width="800"
xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:dashboard="clr-namespace:DevExpress.DashboardWpf;assembly=DevExpress.Dashboard.v22.2.Wpf">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="49*" />
<RowDefinition Height="520*" />
</Grid.RowDefinitions>
<dashboard:DashboardControl x:Name="dashboardControl1" Grid.Row="1" />
<dx:SimpleButton Content="Click to update extract data file" HorizontalAlignment="Left" Margin="24,5,0,0" Grid.Row="0" VerticalAlignment="Top" Width="215" Click="Button_Click" Height="29" />
</Grid>
</dx:ThemedWindow>