Export (0) Print
Expand All

Using the Paging Methods

The ICluster interface contains several methods that let you page through the output that the method generates. These methods are useful if the method might generate a large volume of output and you want to present the data in a user interface as it is generated, instead of waiting until all the data is returned.

The following ICluster methods provide paging:

The paging methods are meant to be called in a loop. The first call takes a snapshot of the output and returns the first page of the output. For ListAllJobsWithPaging, ListJobsWithPaging, and ListTasksWithPaging, be sure to set the Timestamp and Version parameters to NULL on the first call and do not change their values on subsequent calls. The loop ends when the enumerable object is empty.

To reset the enumerable object to the beginning, set Timestamp to NULL and leave the Version value unchanged.

For the methods that list jobs and tasks, you can set Version to NULL and leave the Timestamp value unchanged to get jobs or tasks that were added or whose state has changed since the last snapshot.

The following example shows how to use the ListAllJobsWithPaging method to list all jobs in the cluster.


            // Set pageSize to an appropriate value for your use. The value
            // indicates the number of jobs to return with each page.
            int pageSize = 100; 
            bool hasJobs = true;
            object timestamp = null;
            object version = null;

            while (hasJobs)
            {
                hasJobs = false;

                foreach (IJob job in cluster.ListAllJobsWithPaging(false, ref timestamp, ref version, pageSize))
                {
                    Console.WriteLine(job.Name);

                    foreach (ITask task in job)
                    {
                        if (string.IsNullOrEmpty(task.Name))
                            Console.WriteLine("\t" + task.Id);
                        else
                            Console.WriteLine("\t" + task.Id);
                    }

                    hasJobs = true;
                }

                Console.WriteLine();
            }


Related topics

Using CCP

 

 

Show:
© 2014 Microsoft