예제 #1
0
        private async Task InitialiseAsync()
        {
            if (!this.initialised)
            {
                try
                {
                    this.storageAccount = this.GetStorageAccount();

                    this.client = Retriable.Retry(() => this.storageAccount.CreateCloudBlobClient());

                    string containerName = this.GetContainerName();
                    this.container = Retriable.Retry(() => this.client.GetContainerReference(containerName));

                    if (await this.container.CreateIfNotExistsAsync().ConfigureAwait(false))
                    {
                        var containerPermissions = new BlobContainerPermissions {
                            PublicAccess = BlobContainerPublicAccessType.Off
                        };

                        await Retriable.RetryAsync(() => this.container.SetPermissionsAsync(containerPermissions)).ConfigureAwait(false);
                    }

                    this.initialised = true;
                }
                catch (Exception ex)
                {
                    throw new InitializationFailureException("Initialization failed.", ex);
                }
            }
        }
예제 #2
0
        private static void Run()
        {
            // Here we just retry some non-async service call
            ISomeService someTasks = new MyService();

            var result = Retriable.Retry(() => someTasks.SecondTask(someTasks.FirstTask()));

            Console.WriteLine(result);
        }