The requested page is not available for the requested platform. You are viewing the content for .NET Framework 4.5.2+ platform.
All docs
V19.2
19.2
19.1
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.CommitChangesAsync(CancellationToken) Method

Asynchronously saves all the changes made to the persistent objects belonging to the current Object Space to the database.

Namespace: DevExpress.ExpressApp.Xpo

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

Declaration

public Task CommitChangesAsync(
    CancellationToken cancellationToken = null
)
Public Function CommitChangesAsync(
    cancellationToken As CancellationToken = Nothing
) As Task
public Task CommitChangesAsync(
    CancellationToken cancellationToken = default(CancellationToken)
)
Public Function CommitChangesAsync(
    cancellationToken As CancellationToken = Nothing
) As Task
public Task CommitChangesAsync(
    CancellationToken cancellationToken = default(CancellationToken)
)
Public Function CommitChangesAsync(
    cancellationToken As CancellationToken = Nothing
) As Task

Parameters

Name Type Description
cancellationToken CancellationToken

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

Parameters

Name Type Description
cancellationToken CancellationToken

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

Parameters

Name Type Description
cancellationToken CancellationToken

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

Returns

Type Description
Task

A Task object.

Returns

Type Description
Task

A Task object.

Returns

Type Description
Task

A Task object.

Remarks

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.Win;
using DevExpress.ExpressApp.Xpo;
using DevExpress.Persistent.Base;
using DevExpress.XtraSplashScreen;
using System.Threading;
using System.Windows.Forms; 
// ...
public class AsyncChangeDueDateController : ObjectViewController<DetailView, DemoTask> {
    public AsyncChangeDueDateController() {
        SimpleAction changeDueDateAction =
            new SimpleAction(this, "ChangeDueDate", PredefinedCategory.Edit);
        changeDueDateAction.SelectionDependencyType = SelectionDependencyType.RequireSingleObject;
        changeDueDateAction.Execute += ChangeDueDateAction_Execute;
    }
    async private void ChangeDueDateAction_Execute(object sender, SimpleActionExecuteEventArgs e) {
        IOverlaySplashScreenHandle handle = null;
        Control control = Frame.Template as Control;
        WinApplication application = Application as WinApplication;
        CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
        ViewCurrentObject.DueDate = new System.DateTime(2019,10,21);
        try {
            if (control != null && control.IsHandleCreated) {
                handle = application.StartOverlayForm(control);
            }
            await ((XPObjectSpace)ObjectSpace).CommitChangesAsync(cancellationTokenSource.Token);
        }
        finally {
            if (handle != null) {
                application.StopOverlayForm(handle);
            }
        }
    }
}

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