public override void ExecuteCmdlet()
        {
            ListTaskOptions options = new ListTaskOptions(this.BatchContext, this.JobId,
                                                          this.Job, this.AdditionalBehaviors)
            {
                TaskId   = this.Id,
                Filter   = this.Filter,
                MaxCount = this.MaxCount
            };

            // The enumerator will internally query the service in chunks. Using WriteObject with the enumerate flag will enumerate
            // the entire collection first and then write the items out one by one in a single group.  Using foreach, we can take
            // advantage of the enumerator's behavior and write output to the pipeline in bursts.
            foreach (PSCloudTask task in BatchClient.ListTasks(options))
            {
                WriteObject(task);
            }
        }
Пример #2
0
        /// <summary>
        /// Waits for the specified task to complete
        /// </summary>
        public static void WaitForTaskCompletion(BatchController controller, BatchAccountContext context, string jobId, string taskId)
        {
            RequestInterceptor interceptor = CreateHttpRecordingInterceptor();

            BatchClientBehavior[] behaviors = new BatchClientBehavior[] { interceptor };
            BatchClient           client    = new BatchClient(controller.BatchManagementClient, controller.ResourceManagementClient);

            ListTaskOptions options = new ListTaskOptions(context, jobId, null, behaviors)
            {
                TaskId = taskId
            };
            IEnumerable <PSCloudTask> tasks = client.ListTasks(options);

            // Save time by not waiting during playback scenarios
            if (HttpMockServer.Mode == HttpRecorderMode.Record)
            {
                TaskStateMonitor monitor = context.BatchOMClient.Utilities.CreateTaskStateMonitor();
                monitor.WaitAll(tasks.Select(t => t.omObject), TaskState.Completed, TimeSpan.FromMinutes(2), null);
            }
        }
        /// <summary>
        /// Waits for the specified task to complete
        /// </summary>
        public static void WaitForTaskCompletion(BatchController controller, BatchAccountContext context, string workItemName, string jobName, string taskName)
        {
            YieldInjectionInterceptor interceptor = CreateHttpRecordingInterceptor();

            BatchClientBehavior[] behaviors = new BatchClientBehavior[] { interceptor };
            BatchClient           client    = new BatchClient(controller.BatchManagementClient, controller.ResourceManagementClient);

            ListTaskOptions options = new ListTaskOptions()
            {
                Context             = context,
                WorkItemName        = workItemName,
                JobName             = jobName,
                TaskName            = taskName,
                AdditionalBehaviors = behaviors
            };
            IEnumerable <PSCloudTask> tasks = client.ListTasks(options);

            ITaskStateMonitor monitor = context.BatchOMClient.OpenToolbox().CreateTaskStateMonitor();

            monitor.WaitAll(tasks.Select(t => t.omObject), TaskState.Completed, TimeSpan.FromMinutes(2), null, behaviors);
        }