Click here to Skip to main content
16,016,781 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Senario:

there is a list consisting of items with scheduled date and time,we need to iterate through the list based on the scheduled date and time.Mean while we are giving the user a choice to update or re-schedule date and time for non iterated list items.

thing is that we need to pause the iteration and continue along with latest updates.

ex: list

step1:

for(int i=0;i<=items.count;i++)
{
if(process.ispaused)
{
break the loop; ///here user must be able to update the current list .

}

else
{
iterate through items

}

}

what we are doing is : we are using background worker process .


in doworker event we are not able to pause the loop.please help me out to come up with the issue. we are not able to pause the thread.
Posted

1 solution

The only way to pause a loop is to use Thread.Sleep and then when the sleep ends, check if it's supposed to keep sleeping or not. Overall, your design sounds wrong to me. You should only take a moment to refresh a list, you should not do that so constantly that you need to stop updating to allow new entries to be added.
 
Share this answer
 

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