This example demonstrates how to submit a job for execution and then wait until execution has completed.
The Execute method returns a collection of all the instances created for the execution request (there may be more than one instance if the job runs in a queue that targets multiple agents). To wait for completion, you must periodically refresh the status of each of these instances until all have finished running.