AWSSDK.Tests.Framework.MissingAPILambdaFunctions.CreateBucket C# (CSharp) Method

CreateBucket() public static method

public static CreateBucket ( string bucketName, RegionEndpoint region, bool waitForSuccess = true ) : void
bucketName string
region Amazon.RegionEndpoint
waitForSuccess bool
return void
        public static void CreateBucket(string bucketName, RegionEndpoint region, bool waitForSuccess = true)
        {
            DateTime timeout = DateTime.Now + TimeSpan.FromMinutes(10);
            AutoResetEvent ars = new AutoResetEvent(false);
            string functionError = null;
            Exception responseException = new Exception();
            while (DateTime.Now < timeout)
            {
                string payload = string.Format(@"{{""BucketName"":""{0}"",""Region"":""{1}""}}", bucketName, region.SystemName);
                LambdaClient.InvokeAsync(new InvokeRequest()
                {
                    FunctionName = CreateBucketFunctionName,
                    InvocationType = InvocationType.RequestResponse,
                    Payload = payload
                }, (response) =>
                {
                    responseException = response.Exception;
                    if (responseException == null)
                    {
                        functionError = response.Response.FunctionError;
                    }
                    ars.Set();
                }, new AsyncOptions { ExecuteCallbackOnMainThread = false });
                ars.WaitOne();
                if (responseException != null)
                {
                    throw responseException;
                }
                if (string.IsNullOrEmpty(functionError))
                {
                    break;
                }
                Thread.Sleep(TimeSpan.FromSeconds(30));
            }
            Utils.AssertStringIsNullOrEmpty(functionError);
        }