Skip to main content

FederationDataSource.FillAsync(String[], CancellationToken) Method

Populates the FederationDataSource in an asynchronous manner and uses the cancellationToken parameter to send the cancellation signal. You can specify which queries to execute.

Namespace: DevExpress.DataAccess.DataFederation

Assembly: DevExpress.DataAccess.v23.1.dll

NuGet Package: DevExpress.DataAccess


public Task FillAsync(
    string[] queriesToFill,
    CancellationToken cancellationToken


Name Type Description
queriesToFill String[]

Queries to execute in order to populate the data source.

cancellationToken CancellationToken

A cancellation token that the task observes.


Type Description

A task that populates the data source.


Use this method to populate a federated data source in an individual task asynchronously. Unlike the Fill() method call, FillAsync does not lock other actions performed concurrently. For instance, the user interface remains operational while the data source is populated.

Call the FillAsync method with the await operator.

The queriesToFill array specifies the names of the queries to execute in order to populate the data source.

The cancellationToken parameter provides a way to send the cancellation signal to the task. The task monitors the token and stops when it receives the signal. Create a CancellationTokenSource class instance and pass its Token property to the FillAsync method call. Call the CancellationTokenSource.Cancel method to stop the task.


The code sample below creates a federated data source and populates the CategoriesProducts data member in an asynchronous manner. A CancellationTokenSource class instance is used to allow users to interrupt the data source fill process if it takes too long.

using DevExpress.DataAccess;
using DevExpress.DataAccess.Sql;
using DevExpress.DataAccess.Excel;
using DevExpress.DataAccess.DataFederation;
using DevExpress.DataAccess.ObjectBinding;
using DevExpress.DataAccess.ConnectionParameters;
using System.IO;
using System.Threading;
// The cancellationTokenSource allows users to stop the task.
CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
// Creates and configures an SQL data source.
SqlDataSource sqlDataSource = new SqlDataSource(
    new Access97ConnectionParameters(
        "Data/nwind.mdb"), "", ""))
{ Name = "Sql_Categories" };
var categoriesQuery = SelectQueryFluentBuilder

// Creates and configures an Excel data source.
ExcelDataSource excelDataSource = new ExcelDataSource() { Name = "Excel_Products" };
excelDataSource.FileName = "Products.xlsx";
excelDataSource.SourceOptions = new ExcelSourceOptions()
    ImportSettings = new ExcelWorksheetSettings("Sheet"),

// Creates and configures a federated data source.
FederationDataSource federationDataSource = new FederationDataSource();

Source sourceCategories = new Source(sqlDataSource.Name, sqlDataSource, "Categories");
Source sourceProducts = new Source(excelDataSource.Name, excelDataSource, "Products");

SelectNode selectNode = sourceCategories.From().Select("CategoryName")
    .Join(sourceProducts, "[Excel_Products.CategoryID] = [Sql_Categories.CategoryID]")
    .Select("CategoryID", "ProductName", "UnitPrice")

// Populates the data source's CategoriesProducts query.
await federationDataSource.FillAsync(
    new[] { "CategoriesProducts" },
See Also