All docs
V19.2
19.2
19.1
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.
.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+
.NET Core 3.0+

XPObjectSpace.ReloadObjectAsync(Object, CancellationToken) Method

Asynchronously reloads the state of the specified persistent object and its aggregated objects from the data store.

Namespace: DevExpress.ExpressApp.Xpo

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

Declaration

public Task<object> ReloadObjectAsync(
    object obj,
    CancellationToken cancellationToken = null
)
Public Function ReloadObjectAsync(
    obj As Object,
    cancellationToken As CancellationToken = Nothing
) As Task(Of Object)
public Task<object> ReloadObjectAsync(
    object obj,
    CancellationToken cancellationToken = default(CancellationToken)
)
Public Function ReloadObjectAsync(
    obj As Object,
    cancellationToken As CancellationToken = Nothing
) As Task(Of Object)
public Task<object> ReloadObjectAsync(
    object obj,
    CancellationToken cancellationToken = default(CancellationToken)
)
Public Function ReloadObjectAsync(
    obj As Object,
    cancellationToken As CancellationToken = Nothing
) As Task(Of Object)

Parameters

Name Type Description
obj Object

An object which represents the persistent object whose state needs to be reloaded.

cancellationToken CancellationToken

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

Parameters

Name Type Description
obj Object

An object which represents the persistent object whose state needs to be reloaded.

cancellationToken CancellationToken

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

Parameters

Name Type Description
obj Object

An object which represents the persistent object whose state needs to be reloaded.

cancellationToken CancellationToken

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

Returns

Type Description
Task<Object>

A Task that returns an object. This object is the object specified by the obj parameter after it has been reloaded.

Returns

Type Description
Task<Object>

A Task that returns an object. This object is the object specified by the obj parameter after it has been reloaded.

Returns

Type Description
Task<Object>

A Task that returns an object. This object is the object specified by the obj parameter after it has been reloaded.

Remarks

If the specified persistent object is a new object, the ReloadObjectAsync method does nothing. To ensure that the persistent object is not a new object, use the XPObjectSpace.IsNewObject method.

It is not required that the specified object belong to the current Object Space. If it does not belong, it is retrieved by the current Object Space, and then its state is reloaded.

A CannotReloadPurgedObjectException is thrown if the specified persistent object is permanently deleted from the data store.

The following code demonstrates how you can use this method in a View Controller to refresh a List View after a user changes an object on a Detail View and commits these changes. In this scenario, the List View should be read-only.

using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Actions;
using DevExpress.ExpressApp.Win.Editors;
using DevExpress.ExpressApp.Xpo;
using System.Threading;
// ...
public class AsyncUpdateListViewController : ObjectViewController<ListView, DemoTask> {
    public AsyncUpdateListViewController() : base() {
        SimpleAction updateListViewAction = new SimpleAction(this, "Open assigned contact", "Edit");
        updateListViewAction.SelectionDependencyType = SelectionDependencyType.RequireSingleObject;
        updateListViewAction.Execute += updateListViewAction_Execute;
    }
    private void updateListViewAction_Execute(object sender, SimpleActionExecuteEventArgs e) {
        object assignedContact = ViewCurrentObject.AssignedTo;
        IObjectSpace contactObjectSpace = Application.CreateObjectSpace(assignedContact.GetType());
        View contactView = Application.CreateDetailView(contactObjectSpace, contactObjectSpace.GetObject(assignedContact), true);
        e.ShowViewParameters.CreatedView = contactView;
        contactObjectSpace.Committed += async (s, args) => {
            CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
            await ((XPObjectSpace)ObjectSpace).ReloadObjectAsync(assignedContact, cancellationTokenSource.Token);
            if (View.Editor is GridListEditor) {
                GridListEditor gridListEditor = (GridListEditor)View.Editor;
                gridListEditor.GridView.LayoutChanged();
            }
        };
    }
}

In the current example, the cancellationToken parameter is used for demonstration purposes. You can skip it or use to cancel an asynchronous operation as shown in the CancellationToken topic.

See Also