473,395 Members | 2,796 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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("ActiveConnections") + 1 > Application("PermitConnections")
'If StartTime.AddMinutes(1) < Now Then
Me.LblMessage1.Text = "Two当前数据库访问用户太多,请稍后 使用该报表!"
Me.LblMessage1.CssClass = "ERROR"
Return False
'End If
Loop
Application("ActiveConnections") = Application("ActiveConnections") + mDataRow(0).Item("FORBIDCONN")
If Application("ActiveConnections") > Application("PeakConnections") Then Application("PeakConnections") = Application("ActiveConnections")
End If
Finally
End Try
Return True
End Function
Lei Guangfu(雷光富)

Jul 21 '05 #1
1 1722
Elp

"Lei Guangfu" <Lei Gu*****@discussions.microsoft.com> wrote in message
news:B0**********************************@microsof t.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.Threading.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
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...
1
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...
8
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...
1
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...
1
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...
2
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,...
4
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
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...
16
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. --...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...

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.