Auto Paginate Long Running Tasks

Many times we need to push a huge chunk of data (list) to a web service, problem is mostly web service providers will timeout your request....

            int batchSize = 400;
            int breakBy = System.Convert.ToInt32( Math.Ceiling((double)batch.Count() / batchSize)); // (this gives how many pages we talking)

            for (int i = 0; i < breakBy; i++)
            {
                var emailsThisBatch = batch.Skip(batchSize * i).Take(batchSize).ToList();
                input.parms.batch = emailsThisBatch;

                System.Threading.Thread.Sleep(7000);

          }
Posted by:

No comments posted.

Name :  

Email :  

Comment Below