public static Task DeleteAsync(this CloudTable tbl, TableRequestOptions opt, OperationContext ctx, CancellationToken token) { ICancellableAsyncResult result = null; if (opt == null && ctx == null) { result = tbl.BeginDelete(null, null); } else { result = tbl.BeginDelete(opt, ctx, null, null); } var cancellationRegistration = token.Register(result.Cancel); return(Task.Factory.FromAsync(result, ar => { cancellationRegistration.Dispose(); try { tbl.EndDelete(ar); } catch (StorageException se) { // Todo: Use the PnP azure retry block here for transient exceptions throw; } })); }
/// <summary> /// Deletes a table asynchronously. /// </summary> /// <param name="cloudTable">Cloud table.</param> /// <param name="cancellationToken">Cancellation token.</param> /// <returns>Task.</returns> public static Task DeleteAsync( this CloudTable cloudTable, CancellationToken cancellationToken = default(CancellationToken)) { ICancellableAsyncResult asyncResult = cloudTable.BeginDelete(null, null); CancellationTokenRegistration registration = cancellationToken.Register(p => asyncResult.Cancel(), null); return(Task.Factory.FromAsync( asyncResult, result => { registration.Dispose(); cloudTable.EndDelete(result); })); }
public void EndDelete(IAsyncResult asyncResult) { _cloudTable.EndDelete(asyncResult); }