Back to Devexpress

JsonDataSource.FillAsync() Method

corelibraries-devexpress-dot-dataaccess-dot-json-dot-jsondatasource-33ec1c5b.md

latest3.0 KB
Original Source

JsonDataSource.FillAsync() Method

Populates JsonDataSource with data in an asynchronous manner.

Namespace : DevExpress.DataAccess.Json

Assembly : DevExpress.DataAccess.v25.2.dll

NuGet Package : DevExpress.DataAccess

Declaration

csharp
public Task FillAsync()
vb
Public Function FillAsync As Task

Returns

TypeDescription
Task

A task that populates the data source.

|

Remarks

Use this method to populate a JSON 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.

Handle the FillError event, or catch the JsonDataSourceException exception, to process the case when the FillAsync method failed to populate the data source.

Example

The code sample below creates a JsonDataSource and populates it with data in an asynchronous manner.

csharp
using System.Threading;
using System.Threading.Tasks;
using DevExpress.DataAccess;
using DevExpress.DataAccess.Json;
// ...
// Create a new JSON source.
var jsonSource = new UriJsonSource() {
    Uri = new Uri(@"https://raw.githubusercontent.com/DevExpress-Examples/DataSources/master/JSON/customers.json")
};
// Assign the JSON source to the data source.
var datasource = new JsonDataSource() {
    JsonSource = jsonSource
};
await datasource.FillAsync();
report.DataSource = datasource;
vb
Imports System.Threading
Imports System.Threading.Tasks
Imports DevExpress.DataAccess
Imports DevExpress.DataAccess.Json
' ...
' Create a new JSON source.
Dim jsonSource = New UriJsonSource() With {.Uri = New Uri("https://raw.githubusercontent.com/DevExpress-Examples/DataSources/master/JSON/customers.json")}
' Assign the JSON source to the data source.
Dim datasource = New JsonDataSource() With {.JsonSource = jsonSource}
Await datasource.FillAsync()
report.DataSource = datasource

See Also

JsonDataSource Class

JsonDataSource Members

DevExpress.DataAccess.Json Namespace