示例#1
0
        /// <summary>
        ///     Gets the properties of the table service asynchronously.
        /// </summary>
        /// <param name="tableClient">Cloud table client.</param>
        /// <param name="cancellationToken">Cancellation token.</param>
        /// <returns>Task.</returns>
        public static Task <ServiceProperties> GetServicePropertiesAsync(
            this CloudTableClient tableClient,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            ICancellableAsyncResult       asyncResult  = tableClient.BeginGetServiceProperties(null, null);
            CancellationTokenRegistration registration = cancellationToken.Register(p => asyncResult.Cancel(), null);

            return(Task <ServiceProperties> .Factory.FromAsync(
                       asyncResult,
                       result =>
            {
                registration.Dispose();
                return tableClient.EndGetServiceProperties(result);
            }));
        }
 public ICancellableAsyncResult BeginGetServiceProperties(AsyncCallback callback, object state)
 {
     return(_cloudTableClient.BeginGetServiceProperties(callback, state));
 }