public void TableServiceContextSaveChangeWithRetriesAPM() { CloudTableClient tableClient = GenerateCloudTableClient(); // Get data context. TableServiceContext context = tableClient.GetTableServiceContext(); // Create the new entity. BaseEntity entity = new BaseEntity("Hello", "world."); using (AutoResetEvent waitHandle = new AutoResetEvent(false)) { // Add the entity. context.AttachTo(this.currentTable.Name, entity); context.UpdateObject(entity); // Save changes to the service. IAsyncResult result = context.BeginSaveChangesWithRetries(ar => waitHandle.Set(), null); waitHandle.WaitOne(); context.EndSaveChangesWithRetries(result); BaseEntity entity2 = new BaseEntity("Insert", "foo."); context.AttachTo(this.currentTable.Name, entity2); context.UpdateObject(entity2); // Test again with different parameters result = context.BeginSaveChangesWithRetries(SaveChangesOptions.None, ar => waitHandle.Set(), null); waitHandle.WaitOne(); context.EndSaveChangesWithRetries(result); // Retrieve Entities & Verify BaseEntity retrievedEntity = (from ent in context.CreateQuery <BaseEntity>(currentTable.Name) where ent.PartitionKey == entity2.PartitionKey && ent.RowKey == entity2.RowKey select ent).AsTableServiceQuery(context).Execute().FirstOrDefault(); Assert.IsNotNull(retrievedEntity); retrievedEntity = (from ent in context.CreateQuery <BaseEntity>(currentTable.Name) where ent.PartitionKey == entity.PartitionKey && ent.RowKey == entity.RowKey select ent).AsTableServiceQuery(context).Execute().FirstOrDefault(); Assert.IsNotNull(retrievedEntity); } // Test Dispose context.Dispose(); }