The requested page is not available for the requested platform. You are viewing the content for Default platform.
All docs
19.2 (EAP/Beta)
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
The page you are viewing does not exist in version 17.2. This link will take you to the root page.

XPObjectSpace.PreFetchAsync(Object, String[], CancellationToken) Method

Asynchronously forces associated collection data loading and delayed property loading for specified parent objects.

Namespace: DevExpress.ExpressApp.Xpo

Assembly: DevExpress.ExpressApp.Xpo.v19.2.dll


public Task PreFetchAsync(
    object collection,
    string[] propertyNames,
    CancellationToken cancellationToken = default(CancellationToken)
Public Function PreFetchAsync(
    collection As Object,
    propertyNames As String(),
    cancellationToken As CancellationToken = Nothing
) As Task


Name Type Description
collection Object

A collection of parent objects.

propertyNames String[]

An array of strings which are the names of the associated collection properties.

Optional Parameters

Name Type Default Description
cancellationToken CancellationToken null

A CancellationToken object that delivers a cancellation notice to the running operation.


Type Description

A Task object.


The following code demonstrates how you can use this method in a WinForms-specific View Controller.

using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Actions;
using DevExpress.ExpressApp.Xpo;
using MainDemo.Module.BusinessObjects;
using System;
using System.Threading;
// ...
public class AsyncAssignedToInfoController : ObjectViewController<ListView, DemoTask> {
    View contactView = null;
    public AsyncAssignedToInfoController() : base() {
        SimpleAction showAssignedToInfoAction = new SimpleAction(this, "Assigned contact's info", "Edit");
        showAssignedToInfoAction.SelectionDependencyType = SelectionDependencyType.RequireSingleObject;
        showAssignedToInfoAction.Execute += showAssignedToInfoAction_Execute;
    async private void showAssignedToInfoAction_Execute(object sender, SimpleActionExecuteEventArgs e) {
        CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
        XPObjectSpace contactObjectSpace = (XPObjectSpace)Application.CreateObjectSpace(typeof(Contact));
        contactView = Application.CreateDetailView(contactObjectSpace, "Contact_DetailView", true);
        e.ShowViewParameters.CreatedView = contactView;
        Contact obj = null;
        if (ViewCurrentObject.AssignedTo != null) {
            obj = (Contact)await contactObjectSpace.GetObjectAsync(ViewCurrentObject.AssignedTo);
            Contact[] contacts = new Contact[] { obj };
            await contactObjectSpace.PreFetchAsync(contacts, new string[] { "Tasks" });
        if (obj == null) {
            obj = contactObjectSpace.CreateObject<Contact>();
            contactObjectSpace.Committed += contactObjectSpace_Committed;
        contactView.CurrentObject = obj;
    private void contactObjectSpace_Committed(object sender, EventArgs e) {
        ViewCurrentObject.AssignedTo = ObjectSpace.GetObject(contactView.CurrentObject) as Contact;
See Also