private static async Task MainAsync(AccountSettings accountSettings)
        {
            // Use the AccountSettings from the Common project to initialize a BatchClient.
            var credentials = new BatchSharedKeyCredentials(
                accountSettings.BatchServiceUrl,
                accountSettings.BatchAccountName,
                accountSettings.BatchAccountKey);

            using (var batchClient = await BatchClient.OpenAsync(credentials))
            {
                // Create a MetricMonitor.  Once started, this will periodically fetch job metrics
                // (specifically, the counts of tasks in different states) from Azure Batch.
                // The monitor will stop reporting once disposed, so often you would have the monitor
                // as a long-lived member variable, but for demo purposes we use a 'using' statement
                // to ensure disposal.
                using (var monitor = new MetricMonitor(batchClient))
                {
                    // For demo purposes, print the latest metrics every time the monitor updates them.
                    monitor.MetricsUpdated += (s, e) =>
                        {
                            Console.WriteLine();
                            Console.WriteLine(FormatMetrics(monitor.CurrentMetrics));
                        };
                    // Start monitoring.  The monitor will fetch metrics in the background.
                    monitor.Start();

                    // Give the monitor some jobs to report on.
                    var jobSubmitter = new JobSubmitter(batchClient);
                    await jobSubmitter.SubmitJobsAsync();  // Submit a series of jobs over a period of several minutes
                    await Task.Delay(TimeSpan.FromMinutes(2));  // Give the last submitted job time to get under way so we can see it progressing
                    await jobSubmitter.CleanUpJobsAsync();
                    await jobSubmitter.CleanUpPoolIfRequiredAsync();
                }
            }
        }
        private static async Task MainAsync(AccountSettings accountSettings)
        {
            // Use the AccountSettings from the Common project to initialize a BatchClient.
            var credentials = new BatchSharedKeyCredentials(
                accountSettings.BatchServiceUrl,
                accountSettings.BatchAccountName,
                accountSettings.BatchAccountKey);

            using (var batchClient = await BatchClient.OpenAsync(credentials))
            {
                // Create a MetricMonitor.  Once started, this will periodically fetch job metrics
                // (specifically, the counts of tasks in different states) from Azure Batch.
                // The monitor will stop reporting once disposed, so often you would have the monitor
                // as a long-lived member variable, but for demo purposes we use a 'using' statement
                // to ensure disposal.
                using (var monitor = new MetricMonitor(batchClient))
                {
                    // For demo purposes, print the latest metrics every time the monitor updates them.
                    monitor.MetricsUpdated += (s, e) =>
                    {
                        Console.WriteLine();
                        Console.WriteLine(FormatMetrics(monitor.CurrentMetrics));
                    };
                    // Start monitoring.  The monitor will fetch metrics in the background.
                    monitor.Start();

                    // Give the monitor some jobs to report on.
                    var jobSubmitter = new JobSubmitter(batchClient);
                    await jobSubmitter.SubmitJobsAsync();      // Submit a series of jobs over a period of several minutes

                    await Task.Delay(TimeSpan.FromMinutes(2)); // Give the last submitted job time to get under way so we can see it progressing

                    await jobSubmitter.CleanUpJobsAsync();

                    await jobSubmitter.CleanUpPoolIfRequiredAsync();
                }
            }
        }