DevForce Help Reference
SaveChangesAsync(EntityManager,SaveOptions,Action<EntitySaveOperation>,Object) Method
Example 


Options controlling save processing
Callback invoked when asynchronous operation completes
Token identifying the asynchronous operation
Perform an asynchronous SaveChanges operation with the IdeaBlade.EntityModel.SaveOptions specified.
Syntax
'Declaration
 
<ExtensionAttribute()>
Public Overloads Shared Function SaveChangesAsync( _
   ByVal em As EntityManager, _
   ByVal saveOptions As SaveOptions, _
   ByVal userCallback As Action(Of EntitySaveOperation), _
   Optional ByVal userState As Object _
) As EntitySaveOperation
'Usage
 
Dim em As EntityManager
Dim saveOptions As SaveOptions
Dim userCallback As Action(Of EntitySaveOperation)
Dim userState As Object
Dim value As EntitySaveOperation
 
value = EntityManagerAsyncExtensions.SaveChangesAsync(em, saveOptions, userCallback, userState)

Parameters

em
saveOptions
Options controlling save processing
userCallback
Callback invoked when asynchronous operation completes
userState
Token identifying the asynchronous operation
Remarks
Provide a userCallback if you want to be notified when the operation completes. The IdeaBlade.EntityModel.EntitySaveOperation passed to the userCallback will contain the results of the save operation. Use the userState to uniquely identify this call.

The asynchronous save operation cannot itself be cancelled. However, you can cancel the save process on the client before the save starts in a Saving event handler. You can also cancel the save process on the server in an EntityServerSaveInterceptor prior to executing the save to the data source. If you do cancel the save the returned IdeaBlade.EntityModel.SaveResult will indicate that the save processing was cancelled.

Example
public void AsyncSaveSimple() {
  DomainModelEntityManager mgr = new DomainModelEntityManager();

  Customer c1 = new Customer() { CompanyName = "Toys R Us" };
  mgr.AddEntity(c1);
  Customer c2 = new Customer() { CompanyName = "Apple" };
  mgr.AddEntity(c2);

  // Save all modified entities using default SaveOptions.
  // Use a lambda expression which takes the EntitySaveOperation.
  // The userstate token is left null since it's optional.
  mgr.SaveChangesAsync(op => {
    SaveResult sr = op.SaveResult;
    MessageBox.Show(sr.Ok.ToString());
  }, null);
}
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

EntityManagerAsyncExtensions Class
EntityManagerAsyncExtensions Members
Overload List

Send Feedback