Regular and Async Virtual Sources

  • 3 minutes to read

Regular Sources

The GridControl supports the following regular sources:

Virtual Source Description Example
InfiniteSource The infinite source. How to Bind to InfiniteSource
PagedSource The paged source. How to Bind to PagedSource

Workflow

Regular virtual sources raise events consecutively in the UI Thread and process data in a single separate Working Thread.

The image below illustrates the workflow:

VirtualSourcesGeneral

  1. The virtual source creates a single separate Working Thread to process data.
  2. The virtual source raises the InfiniteSource.CreateSource (or PagedSource.CreateSource) event. Handle this event to create an object used to request data (e.g., DbContext for EF, UnitOfWork for XPO).
  3. The virtual source raises the InfiniteSource.GetTotalSummaries (or PagedSource.GetTotalSummaries) event. Handle this event and process summaries if you want to show them in the GridControl.
  4. The virtual source raises the InfiniteSource.FetchRows (or PagedSource.FetchPage) event to get the first portion of data.
  5. When end-users navigate to the next page, the virtual source raises the InfiniteSource.FetchRows (or PagedSource.FetchPage) event to get the next portion of data.
  6. When end-users apply a filter, the virtual source raises the InfiniteSource.GetUniqueValues (or PagedSource.GetUniqueValues) event to get unique values and show them in a drop-down filter.
NOTE

Only values of the Char, SByte, Byte, Int16, UInt16, Int32, UInt32, Int64, UInt64, Single, Double, Decimal, DateTime, String, Guid, Enum types are available in the UI Thread.

For other types, the UI Thread creates thread-safe proxy objects. You can allow access to these values in the following ways:

Async Sources

The GridControl supports the following async sources:

Virtual Source Description Example
InfiniteAsyncSource The asynchronous infinite source. How to Bind to InfiniteAsyncSource
PagedAsyncSource The asynchronous paged source. How to Bind to PagedAsyncSource

Workflow

Async virtual sources raise events in the UI Thread and process data in parallel Working Threads. You have to provide tasks to these events to obtain summaries, rows, etc.

The image below illustrates the workflow:

VirtualSourcesAsync

  1. The virtual source raises the InfiniteAsyncSource.GetTotalSummaries (or PagedAsyncSource.GetTotalSummaries) event. Handle this event and process summaries if you want to show them in the GridControl.
  2. The virtual source raises the InfiniteAsyncSource.FetchRows (or PagedAsyncSource.FetchPage) event to get the first portion of data.
  3. When end-users navigate to the next page, the virtual source raises the InfiniteAsyncSource.FetchRows (or PagedAsyncSource.FetchPage) event to get the next portion of data.
  4. When end-users apply a filter, the virtual source raises the InfiniteAsyncSource.GetUniqueValues (or PagedAsyncSource.GetUniqueValues) event to get unique values and show them in a drop-down filter.
NOTE

Async virtual sources have the following advantages because they fetch rows in parallel threads:

  • You do not have to wait for rows to be loaded to show summaries.
  • If you quickly move from one page to another, the PagedAsyncSource loads all data pages. The PagedSource loads only the last page and throttles requests to other pages.

When to Use Async Sources

Use the async virtual sources in the following cases:

  • Case 1

    A data source supports asynchrony (for example, .NET MongoDB Driver provides methods to perform multiple requests at the same time).

  • Case 2

    You can create a new data access object (for example, DbContext) for every request.

    NOTE

    Do not use async sources if a data access object

    • is created for a long time, or
    • takes an extensive amount of time to perform the first request.