如何让进程睡眠并重新启动它?

编程入门 行业动态 更新时间:2024-10-28 04:15:30
本文介绍了如何让进程睡眠并重新启动它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

Hai, 我在VS2012中使用控制台应用程序。 我想从MS Access DataBase更新员工信息(有超过70000条记录。 )。 因为服务器无法同时加载所有记录,我需要让我的进程休眠一分钟,它必须从它已经停止的记录开始。 /> for exmaple, 我使用的是for循环,

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,

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) } }

现在在else部分,线程休眠一分钟,但我不知道如何从线程已经睡眠的记录中再次启动进程。 即 eg),循环进入第199个记录并睡眠一分钟。 然后它应该从第200个记录开始并在第399个记录之后休眠并继续...... 先谢谢!!!

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!!!

推荐答案

使用 MOD ,类似 if((i%200)=! 0)。然而,以这种方式编程是非常糟糕的做法。所以你可能想要一起寻找更好的解决方案。 祝你好运! 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!

首先,更新您的记录作为应用程序的一部分。第一种方法中的分钟间隔不适用于更新查询,如果您在每次注册的1分钟范围内添加此片段,您将在上次更新时继续。 部分将Select Value与TableName分开可以使用TOP 10 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

Hai, 我通过简单地删除If .. Else语句来解决自己/> ie), 我用过: for(int i = 0; i< 200; i ++) { while(dbReader.Read()) { //逻辑在这里。 System.Threading.Thread.sleep(60000)//它睡了1分钟。 继续; //每次睡眠后循环继续,直到达到极限。 /> } } 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. } }

更多推荐

如何让进程睡眠并重新启动它?

本文发布于:2023-07-06 20:35:25,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1054513.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:重新启动   睡眠   进程

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!