DbContext::SaveChangesAsync Method (CancellationToken)

[This page is specific to the Entity Framework version 6. The latest version is available as the 'Entity Framework' NuGet package. For more information about Entity Framework, see msdn.com/data/ef.]

Asynchronously saves all changes made in this context to the underlying database.

Namespace:  System.Data.Entity
Assembly:  EntityFramework (in EntityFramework.dll)

[SuppressMessageAttribute(L"Microsoft.Usage", L"CA1801:ReviewUnusedParameters", MessageId = L"cancellationToken")]
public:
virtual Task<int>^ SaveChangesAsync(
	CancellationToken cancellationToken
)

Parameters

cancellationToken
Type: System.Threading::CancellationToken
A CancellationToken to observe while waiting for the task to complete.

Return Value

Type: System.Threading.Tasks::Task<Int32>
A task that represents the asynchronous save operation. The task result contains the number of objects written to the underlying database.

ExceptionCondition
InvalidOperationException

Thrown if the context has been disposed.

Multiple active operations on the same context instance are not supported. Use 'await' to ensure that any asynchronous operations have completed before calling another method on this context.

Show: