Skip to main content

InfiniteSource Class

The infinite source. This source is obsolete. Use the InfiniteAsyncSource instead.

Namespace: DevExpress.Xpf.Data

Assembly: DevExpress.Xpf.Core.v24.1.dll

NuGet Package: DevExpress.Wpf.Core

Declaration

public sealed class InfiniteSource :
    InfiniteSourceBase

Remarks

Refer to the Virtual Sources topic to learn more.

VirtualSourcesTutorialAll

Important

The InfiniteSource is obsolete. Use the InfiniteAsyncSource instead.

Workflow

The InfiniteSource raises events consecutively in the UI Thread and processes data in a single separate Working Thread.

  1. The InfiniteSource creates a single separate Working Thread to process data.
  2. The InfiniteSource raises the InfiniteSource.CreateSource event. Handle this event to create an object used to request data (for example, DbContext for EF, UnitOfWork for XPO).
  3. (Optional step) The InfiniteSource raises the InfiniteSource.GetTotalSummaries event. Handle this event and process summaries if you want to show them in the GridControl.
  4. The InfiniteSource raises the InfiniteSource.FetchRows event to get the first portion of data.
  5. When users navigate to the next page, the InfiniteSource raises the InfiniteSource.FetchRows event to get the next portion of data.
  6. (Optional step) When end users apply a filter, the InfiniteSource raises the InfiniteSource.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:

Tips

  • In addition to the InfiniteSource.FetchRows event, you should handle the InfiniteSource.CreateSource and InfiniteSource.DisposeSource events:

    source.CreateSource += (o, e) => {
        e.Source = new IssuesContext();
    };
    source.DisposeSource += (o, e) => {
        var issuesContext = (IssuesContext)e.Source;
        issuesContext.Dispose();
    };
    
  • Get the IssuesContext before obtaining rows:

    static FetchRowsResult FetchRows(FetchRowsEventArgs e) {
        // ...
        var issuesContext = (IssuesContext)e.Source;            
        var issues = issuesContext.GetIssues(
        page: e.Skip / pageSize, 
        pageSize: pageSize, 
        sortOrder: sortOrder, 
        filter: filter);
        // ...
    }
    static object[] GetTotalSummaries(GetSummariesEventArgs e) {
        // ...
        var issuesContext = (IssuesContext)e.Source;
        var summaryValues = issuesContext.GetSummaries(filter);
        // ...
    }
    
  • In the InfiniteSource.FetchRows handler, return a list of objects separately and specify the FetchRowsEventArgs.HasMoreRows property:

    source.FetchRows += (o, e) => {
        var fetchRowsResult = FetchRows(e);
        e.Result = fetchRowsResult.Rows;
        e.HasMoreRows = fetchRowsResult.HasMoreRows;
    };
    
See Also