Click here to Skip to main content
15,920,603 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hai,
I am using a console application in VS2012.
I want to update the employee information from the MS Access DataBase(More than 70000 records are there.).
since the server is not able to load all the records at the same time, I need to make my process sleep for one minute and it has to start from the record it has stopped.
for exmaple,
I am using a for loop,
C#
for(int i=0;;i++)
{
   if(i<200)
   {
      while(dbReader.read())
      {
         //Logic goes here
         // it gets the employee details one by one.
      }
   }
   else//when it has reached the limit
   {
      system.Threading.Thread.sleep(60000)
   }
}

Now in the else part the thread sleeps for one minute but I don't know how to start the process again from the record that the thread has slept.
That is,
eg),the loop goes till 199th record and sleeps for one minute.
then it should start from the 200th record and sleeps after 399th record and goes on...

Thanks in Advance!!!
Posted
Updated 10-Sep-14 22:54pm
v2

use MOD, something like if((i % 200) =! 0). It is pretty bad practice to program this way however. So you might want to look into a better solution all together.

Good luck!
 
Share this answer
 
Hi, First of all, update your records as part of the application .Consol minute intervals in the first method did not work with the update query if you add into this piece in the range of 1 minute each registration you will continue where the last update.
Partly to separate the Select Value From TableName can use the TOP 10
 
Share this answer
 
Hai,
I solved myself by simply removing the If.. Else statement
i.e),
I have used:

for(int i=0;i<200;i++)
{
while(dbReader.Read())
{
//Logic goes here.
System.Threading.Thread.sleep(60000)//for 1 minute it sleeps.
continue;//the looping continues after each sleep till it reaches the limit.
}
}
 
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