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)
'Declaration
<SuppressMessageAttribute("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId := "cancellationToken")> _
Public Overridable Function SaveChangesAsync ( _
cancellationToken As CancellationToken _
) As Task(Of Integer)
'Usage
Dim instance As DbContext
Dim cancellationToken As CancellationToken
Dim returnValue As Task(Of Integer)
returnValue = instance.SaveChangesAsync(cancellationToken)
[SuppressMessageAttribute("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "cancellationToken")]
public virtual Task<int> SaveChangesAsync(
CancellationToken cancellationToken
)
[SuppressMessageAttribute(L"Microsoft.Usage", L"CA1801:ReviewUnusedParameters", MessageId = L"cancellationToken")]
public:
virtual Task<int>^ SaveChangesAsync(
CancellationToken cancellationToken
)
[<SuppressMessageAttribute("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "cancellationToken")>]
abstract SaveChangesAsync :
cancellationToken:CancellationToken -> Task<int>
[<SuppressMessageAttribute("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "cancellationToken")>]
override SaveChangesAsync :
cancellationToken:CancellationToken -> Task<int>
public function SaveChangesAsync(
cancellationToken : CancellationToken
) : Task<int>
- cancellationToken
Type: System.Threading.CancellationToken
A CancellationToken to observe while waiting for the task to complete.
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.
Exception | Condition |
---|---|
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.