Exemple #1
0
        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;
                }
            }));
        }
Exemple #2
0
        /// <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);
            }));
        }
Exemple #3
0
 public void EndDelete(IAsyncResult asyncResult)
 {
     _cloudTable.EndDelete(asyncResult);
 }