Exemple #1
0
        public IRetryPolicy CreateInstance()
        {
            EventExponentialRetry newInstance = new EventExponentialRetry(this.deltaBackoff, this.maximumAttempts);

            newInstance.RaiseRetryEvent = this.RaiseRetryEvent;
            return(newInstance);
        }
        /// <summary>
        /// Initializes the sample class, setting up the custom retry policy and its event handler.
        /// </summary>
        public EntityCreator()
        {
            // Retrieve the storage account from the connection string.
            Console.WriteLine("Retrieving storage account");
            string connectionString = ConfigurationManager.AppSettings["StorageConnectionString"];
            CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString);

            // Prepare the retry policy.
            EventExponentialRetry retryPolicy = new EventExponentialRetry(TimeSpan.FromSeconds(2), 10);
            retryPolicy.RaiseRetryEvent += HandleRetryEvent;

            // Create the table client.
            CloudTableClient tableClient = storageAccount.CreateCloudTableClient();
            tableClient.RetryPolicy = retryPolicy;

            // Create the table if it doesn't exist.
            Console.WriteLine("Preparing table.");
            const string tableName = "Sample";
            table = tableClient.GetTableReference(tableName);
            table.CreateIfNotExists();
        }
        /// <summary>
        /// Initializes the sample class, setting up the custom retry policy and its event handler.
        /// </summary>
        public EntityCreator()
        {
            // Retrieve the storage account from the connection string.
            Console.WriteLine("Retrieving storage account");
            string connectionString            = ConfigurationManager.AppSettings["StorageConnectionString"];
            CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString);

            // Prepare the retry policy.
            EventExponentialRetry retryPolicy = new EventExponentialRetry(TimeSpan.FromSeconds(2), 10);

            retryPolicy.RaiseRetryEvent += HandleRetryEvent;

            // Create the table client.
            CloudTableClient tableClient = storageAccount.CreateCloudTableClient();

            tableClient.RetryPolicy = retryPolicy;

            // Create the table if it doesn't exist.
            Console.WriteLine("Preparing table.");
            const string tableName = "Sample";

            table = tableClient.GetTableReference(tableName);
            table.CreateIfNotExists();
        }
 public IRetryPolicy CreateInstance()
 {
     EventExponentialRetry newInstance = new EventExponentialRetry(this.deltaBackoff, this.maximumAttempts);
     newInstance.RaiseRetryEvent = this.RaiseRetryEvent;
     return newInstance;
 }