Click here to Skip to main content
15,893,564 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
whenever a process completed i need to display no of completed process. for example
Completed process 5 of 100. then for next iteration: Completed process 6 of 100.

C#
public JsonResult DoProcess(List<string> data)
    {
        foreach (string str in data)
        {
            try
            {
                System.Threading.Thread.Sleep(2000);// process
                complete++; //global variable initialize with zero.

                if (complete == data.Count)
                    isComplete = true;

            }
            catch (Exception ex)
            {
                var error = new ErrorList
                {
                    ErrorMessage = ex.Message
                };
                complete++;
                if (complete == data.Count)
                    isComplete = true;
                errors.Add(error);
            }
        }
        return Json(errors);
    }
Posted
Comments
Sergey Alexandrovich Kryukov 18-Aug-15 10:43am    
It makes no sense, because the processes are not only complete, but can be started. And any process can start and finish between your iterations, so you won't notice it. It looks like a pointless exercise.
—SA
suzand 18-Aug-15 22:36pm    
Actually if i can display the no of iteration of foreach loop; my purpose will be served. Oh "System.Threading.Thread.Sleep(2000);" this line will be replaced by web service calling. sorry for using word "process".

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900