public async Task CreateShare(string shareName, int retries, int millisecondsBetweenRetries) { while (true) { HttpRequestMessage request = FileTests.CreateShareRequest(FileContext, shareName); Assert.IsTrue(request != null, "Failed to create HttpRequestMessage"); HttpResponseMessage response = await FileTestUtils.GetResponse(request, FileContext); HttpStatusCode statusCode = response.StatusCode; string statusDescription = response.ReasonPhrase; StorageExtendedErrorInformation error = await StorageExtendedErrorInformation.ReadFromStreamAsync(await response.Content.ReadAsStreamAsync()); response.Dispose(); // if the share is being deleted, retry up to the specified times. if (statusCode == HttpStatusCode.Conflict && error != null && error.ErrorCode == FileErrorCodeStrings.ShareBeingDeleted && retries > 0) { Thread.Sleep(millisecondsBetweenRetries); retries--; continue; } Assert.AreNotEqual(HttpStatusCode.NotFound, statusCode, "Failed to create share"); break; } }