473,625 Members | 3,085 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to pause a process for a given time?

Hi,

I have a program need to check the value of a application available, and then decide whether to execute codes followed.

In order to achieve this purpose, I use DO WHILE loop to judge the value, if the value meet the condition clause, program will exit the loop. But this DO WHILE loop consumes too much CPU resource.

Now my question is whether a possible way to pause a process for a given time such as one minute?

Anyone can give me some guide on this issue? Thanks

For better understanding the scenario, please refer to following codes.

Public Function DataAccessBegin () As Boolean
Try
Dim StartTime As DateTime
StartTime = Now
Do While Application("Ac tiveConnections ") + 1 > Application("Pe rmitConnections ")
'If StartTime.AddMi nutes(1) < Now Then
Me.LblMessage1. Text = "Two当前数 库访问用 太多,请 后再使用 报表!"
Me.LblMessage1. CssClass = "ERROR"
Return False
'End If
Loop
Application("Ac tiveConnections ") = Application("Ac tiveConnections ") + mDataRow(0).Ite m("FORBIDCONN ")
If Application("Ac tiveConnections ") > Application("Pe akConnections") Then Application("Pe akConnections") = Application("Ac tiveConnections ")
End If
Finally
End Try
Return True
End Function
Lei Guangfu(雷光 )

Jul 21 '05 #1
1 1745
Elp

"Lei Guangfu" <Lei Gu*****@discuss ions.microsoft. com> wrote in message
news:B0******** *************** ***********@mic rosoft.com...
Hi,

I have a program need to check the value of a application available, and then decide whether to execute codes followed.
In order to achieve this purpose, I use DO WHILE loop to judge the value, if the value meet the condition clause, program will exit the loop. But this
DO WHILE loop consumes too much CPU resource.
Now my question is whether a possible way to pause a process for a given

time such as one minute?

To pause a process, you can use System.Threadin g.Thread.Sleep( x) where x is
the number of milisecond during which you want you process to be suspended.
However, in your particular scenario, i would simply use a Timer (the one in
System.Windows. Form that you can also find in the toolbox of the Window Form
designer) instead of looping and sleeping.
Jul 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1883
by: Andrew | last post by:
When will .NET have a low-pause-time garbage collector A low-pause-time garbage collector would greatly improve .NET's ability to serve as a platform for soft real-time systems. It doesn't have to be perfect. For example, I'd be happy with something where there was at most one pause per second, each pause was less than .2 seconds, and half the process's memory was inaccessible to the application due to garbage collection management It...
1
334
by: Lei Guangfu | last post by:
Hi, I have a program need to delay for a given time, I use DO WHILE loop to achieve this goal, but this method consumes too much CPU resource. So I want to find a way to pause a process for a given time such as one minute. Anyone can offer me some guides? Thanks in advance. For better understanding the scenario, please refer to following codes: Public Function BeginConnection() As Boolean Try
8
36442
by: Wim | last post by:
My GUI application starts a process (a console program) when the user hits Play. I would like to add an option to pause that process. The code I've added to detect if the user hit pause/unpause seems to work. But I have no clue how to pause/suspend the process. As far as I can see the Process class doesn't offer anything for this. So it's probably the thread the process is running on that should be suspended or put to sleep. But just...
1
309
by: Lei Guangfu | last post by:
Hi, I have a program need to check the value of a application available, and then decide whether to execute codes followed. In order to achieve this purpose, I use DO WHILE loop to judge the value, if the value meet the condition clause, program will exit the loop. But this DO WHILE loop consumes too much CPU resource. Now my question is whether a possible way to pause a process for a given time such as one minute? Anyone can give me...
1
1508
by: OBINT | last post by:
Hi I am using one API to do some process for me, but unfortunately API dont have a option of pause the process and resume it back. How can i do this using C# API take more then 2 hours in processing and takes 100% CPU usage, I want a option so that i can pause the COM to work and resume when required. Thanks in advance.
2
2268
by: eSolTec, Inc. 501(c)(3) | last post by:
Thank you in advance for any and all assistance. Is there a way to start, pause and resume a recurrsive search exactly where you left off, say in the registry programmatically? -- Michael Bragg, President eSolTec, Inc. a 501(C)(3) organization MS Authorized MAR looking for used laptops for developmentally disabled.
4
2738
by: =?Utf-8?B?Qm9iQWNoZ2lsbA==?= | last post by:
I need to pause the action of my code for a quarter second or so. What can I use to do this? Thanks! Bob
1
1709
by: Wazza | last post by:
G'Day, I have a re-occurring problem and wish to design a framework or pattern to address it. I have some Ideas but I would like to do some brainstorming with my peers before commencing. The problem: Several computational tasks I am running for my PhD work require several weeks to complete and I will to be able to pause these tasks
16
2811
by: Kapteyn's Star | last post by:
Hello all, I want a function to make the program pause for a few seconds but K&R have not listed anything for this i even looked in index. can anyone help? Thank you very much. -- Kapteyn's Star
0
8259
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
8637
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8502
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7188
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5571
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4090
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4195
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2621
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1805
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.