Delay Loops Without Using (Sleep Or Timer)

Dec 20, 2009

Is there is way to delay loops without using (Sleep or timer) in VB

Because on java you cant do something like this

For(i = 0; i< 100; i++) {

I dont want to use sleep because your control is dead while is at sleep And using timer waste memory and process timer plus more coding is needed!


Creating A Delay In A Loop Without Thread.Sleep()?

Apr 22, 2012

i have a web browser control, that refreshes pages on a loop after calling a few subs, i need to create a delay in the loop so that the page has a chance to refresh and redisplay before it loops again. i tried the code below, but it seemed to freeze the entire form, elements including, so the web browser didnt refresh before the loop, so how could i create a non form-freezing delay for a loop?

For count = 1 To 20


View 4 Replies View Related

Non-locking Sleep/waitfor/delay Function For ASP.NET?

Apr 27, 2011

I am writing an ASP.NET class that interfaces with an external application. The flow of the transaction between the web server and this application is as follows:My object writes a file to a directory.The outside application detects this file and processes it. This can take between 1-5 seconds.The outside application writes a response file to the same directory.My object detects the response file and parses the results.The 1-5 seconds it can take for the external application to process my file is my problem. The most straightforward way to wait for the file seems to be something like this:

Do While Not File.Exists(f)

Of course, Thread.Sleep() completely locks up the rest of my website until the outside application processes the file. Clearly, this is not a workable solution.How can I effectively "wait" for my file to be processed without locking up the rest of my website?

View 1 Replies View Related

VS 2010 Pause / Delay Code (can't Use Sleep Function)

Aug 26, 2010

I have another problem with my bot.


After the 7th line I need a pause until a submit button pops up on the screen. The submit button is hidden until the getelementbyid.focus is run. I cant use webbrowser_documentcompleted because the submit only unhides itself, and I cant use Sleep() because that just stalls the whole block.

View 9 Replies View Related

VS 2008 Timer - Possible To Use A Timer To Delay Code?

Apr 6, 2009

Is it possible to use a timer to delay code? For example:


View 7 Replies View Related

Inconsistant Thread Sleep Timer?

Apr 5, 2011

Ok so I have been playing with and brainstorming ways to accomplish launching a thread reliably every 60 seconds reguardless of how long the prior thread took to do it's work. Here is my question. Given the following code:


My assumption for this output would be that the time between each line would have to be exactly 5000 milliseconds plus the time it takes to execute the rest of the loop which could vary given that there could be an unknown delay due to disk IO. My problem is that looking at lines 10 and 11 and subtracting gives me a difference of 4,958 milliseconds. So my question is what the heck is going on there? How is it possible to get a difference of less than 5000 milliseconds when I have told the thread to sleep for 5000 milliseconds before completing the process. What am I missing?

View 5 Replies View Related

Use "System.Threading.Thread.Sleep(15)" As The Delay Code But Freeze The Form

Jul 19, 2011

I've been trying to use "System.Threading.Thread.Sleep(15)" as the delay code but if freeze the form. I used this "Location.Refresh()" where location is the name of the form, but it didn't give me what I need. This code is going to work on a ProgressBar while typing and the value of the progress bar change while typing. The progress bar jumps to the new value and I want it to move. So I thought about puting it in a "For ... Loop" but the whole form freezes.


View 1 Replies View Related

VS 2008 "System.Threading.Thread.Sleep()" - Showing The Images With A Delay

Dec 31, 2009

I have 5 Picture Boxes, each picture box has an image but all 5 of them has a visibility of false. I have a button, when clicked will show 5 of the images. But showing the 5 images with a delay. So it's going to be


View 6 Replies View Related

.net - Does A Form Timer Maintain State During Sleep/hibernate?

Oct 12, 2010

If I have an event that starts a timer with an interval of say, 30 minutes, and 15 minutes later, the computer the app is running on sleeps (Suspend to RAM) or Hibernates (Suspend to Disk), and is brought back online after ten minutes, will the timer raise its Tick event in 5 minutes (30 minutes REAL time from the start) or 15 minutes (30 minutes RUNTIME from the start)?

View 1 Replies View Related

How To Add Timer Delay

Apr 2, 2010

I'm trying to figure out the best way to add delay. From looking online I believe a timer would work best but I'm having trouble with the code. Basically what I'm trying to accomplish is a GPI debounce set to 200ms. the Timer3 properties interval is set to 200 and its enabled = false. Here is what I am working on.


View 5 Replies View Related

Using A Timer To Create A Delay?

Oct 15, 2009

I'm using Visual Basic 2008 Express Edition.I'm working on a class.  At various points, I want to insert a delay between executions of the code.   Nothing terribly large.  Around 50-200 miliseconds.  It doesn't seem like much, but it makes the program run better.  I'll probably randomize the length of the delay later between those two marks.  So basically the code would go...SomeFunction()timer delaySomeFuntion()I have the timer declared as
Private tmrTimer As TimerAnd each place I want to use it, I simply redeclare it.  Or I might add it to the constructor of the class.  Either way.  Just thinking adding it to the class constructor would probably be a better idea.
tmrTimer =


End SubUnfortunately, I get the error    "Handles clause requires a WithEvents variable defined in the containing type or one of its base types"Now remember, this is all contained in a class, so theoretically speaking I can simply move the class file from project to project and reuse it, without ever having to worry about how the class works. Reading through the Timer specifications, I probably need to do some cleanup on the timer after I use it.  Am I correct in this?   

View 4 Replies View Related

How To Use Timer Function Just As Time Delay

May 29, 2010

What line of code would I need to use the timer function just as a delay, so like as lines are being executed, once it gets to this timer it waits for say 1500 milliseconds before execution is continued.

View 4 Replies View Related

Using A Timer To Delay Main Thread?

Feb 3, 2011

is the first time I tried to use a timer - can't understand why it doesn't work!I need to suspend the main thread for a preset time 'delaymSecs' then let the thread continue.I tried this code fragment:-



View 1 Replies View Related

Interface And Graphics :: Delay In Timer Tick?

Dec 2, 2008

I am running an application to control at 1, 10 and 100 Hz to compare their response for a control systems class. I have a timer that reads data from hardware, a timer that updates the screen and does the control, and a timer that writes data to a file. I've been having problems with the speed of the write timer, so I created a buffer.It takes 0 ms to load the buffer, and the buffer is written to file using a synchronized streamwriter and a thread every 100 iterations. It also flips back and forth between two buffers so there are no read/write conflicts.If I try to run at 10 Hz, the timer executes on average every 109 ms. If I try to run at 100 Hz, the timer executes on average ever 15-16 ms.

View 2 Replies View Related

Force The Timer To Do The Code Within The Tick Event Before The Delay?

Jun 9, 2012

it is possible to force the timer to do the code within the tick event before the delay.In other words..Usually the timer when starts it delays 'x' seconds according to the interval settings then process some codes then delay again 'x' seconds.What I want here is to do the code then delays 'x' seconds.

View 2 Replies View Related

VS 2008 Difference Of Sleep Function And Pause Function (using Timer) Between A Loop

Aug 20, 2009

Hi. what is the difference of sleep function and pause function (using timer) between a loop.

View 12 Replies View Related

VS 2010 - Using System.Threading.Thread.Sleep(5000) To Let My App Pause/sleep For Some Time

May 25, 2010

Currently I'm using System.Threading.Thread.Sleep(5000) to let my app pause/sleep for some time. This works great but I can't open my app anymore when it's sleeping and it uses about 25% of my CPU. I guess there must be a better way to do this. I also tried using a timer but that didn't work out to well for me..

View 5 Replies View Related

Monthly Payment Calculation, For Loops To Do While Loops?

Oct 8, 2011

the purpose of the program is to display the monthly payments on the loan.My homework is to use do while loops instead of for loop.Here is the code for the for loop.

Option Explicit On
Option Strict On
Option Infer Off


Now I'm having some trouble displaying the output using the do while loop, and I'm pretty sure it's a loop problem on my code. However, I cannot seemed to find out what's wrong. I looked at the examples of do while loop in my textbook, but I couldn't find anything useful to my problems of my program.This is the output for the do while loop.

Here's the do while loop code

Option Explicit On
Option Strict On
Option Infer Off


View 3 Replies View Related

Time Delay - Make GUI Program To Delay Before The Next Command

Dec 21, 2009

I know that time delays have been covered before around almost everywhere. however a method that forgoes forcing the GUI to become temporarily non-responsive, is all but a myth, or at least to my findings. i have the need for a GUI program to delay before the next command, however using the current method, detailed following, it causes the desired effect however it dose make it much less polished as when you click anything else on the GUI it goes un-responsive for the directed time. [Code] make a sub called say Tdelay( milseconds as integer) and have it run a loop as many times as the milseconds variable indicates and each time making the thread delay for 1 milsecond and then update the GUI/form in some way, then re-loop.

View 7 Replies View Related

VS 2008 Timer Delay In VS 2008?

Jul 8, 2009

I am using serial port to send packets in a form. There is a delay between two common packets, say 20 seconds. I used to use sleep to delay 20s before the second packet send.But sometimes I need to send a special packet every 4 seconds to keep device alive before the 2nd packet send. But during sleeping I cannot do anything.Per a suggestion yesterday from an expert, I changed to use timer solution. I set Timer1.interval = 4,000 and Timer2.interval = 20,000 and enable Timer1 and Timer2 after the 1st packet in Form1. After the 2nd packet is read to buffer, I use "while" to wait there until 20s overflow in Timer2 to send this common packet out. At the meantime, Timer1 is supposed to overflow every 4s to send the special packet. Now the problem is:

View 7 Replies View Related

Contain Functions(They All Have For Loops) Don't Work In For Loops?

Mar 6, 2011

When I use a For loop in a For loop the Contains Statement dosen't work! Even my custom one! I even tested mine and it works 100% And neither that or the String.Contains function work inside of For Loops And, I know both of them use loops to search through a string.

My function(It will atleast search once):

Function RealContains(ByVal load As String, ByVal needle As String) As Boolean
load = load.ToLower


View 10 Replies View Related

Left Click - Sleep - Move Mouse - Sleep - Moves Mouse To First Location (but Doesn't Click)

Apr 28, 2012

This is the code I am working with...


View 6 Replies View Related

Thread.sleep Precision - Sleep A Thread For A "tick"

Nov 27, 2009

is there anyway to sleep a thread for a "tick". i.e. the tick in StopWatch.ElapsedTick. right now the best i could achieve is this thread.sleep(1). i need it faster

View 13 Replies View Related

Extend My Interval Timer Timer To Include Hours In Addition To Minutes And Seconds?

Aug 2, 2010

What I need to do to make this code work for hours as well?[code]...

View 6 Replies View Related

.net - Accurate Windows Timer - System.Timers.Timer() Is Limited To 15 Msec

Jan 15, 2009

I need an accurate timer to interface a Windows application to a piece of lab equipment.I used System.Timers.Timer() to create a timer that ticks every 10 msec, but this clock runs slow. For example 1000 ticks with an interval of 10 msec should take 10 wall-clock seconds, but it actually takes more like 20 wall-clock sec (on my PC). I am guessing this is because System.Timers.Timer() is an interval timer that is reset every time it elapses. Since it will always take some time between when the timer elapses and when it is reset (to another 10msec) the clock will run slow. This probably fine if the interval is large (seconds or minutes) but unacceptable for very short intervals.Is there a function on Windows that will trigger a procedure every time the system clock crosses a 10 msec (or whatever) boundary?

UPDATE: System.Timers.Timer() is extremely inaccurate for small intervals.I wrote a simple program that counted 10 seconds several ways:

Interval=1, Count=10000, Run time = 160 sec, msec per interval=16
Interval=10, Count=1000, Run time = 16 sec, msec per interval=15
Interval=100, Count=100, Run time = 11 sec, msec per interval=110
Interval=1000, Count=10, Run time = 10 sec, msec per interval=1000

It seems like System.Timers.Timer() cannot tick faster that about 15 msec, regardless of the interval setting.Note that none of these tests seemed to use any measurable CPU time, so the limit is not the CPU, just a .net limitation (bug?)For now I think I can live with an inaccurate timer that triggers a routine every 15 msec or so and the routine gets an accurate system time. Kinda strange, but...I also found a shareware product ZylTimer.NET that claims to be a much more accurate .net timer (resolution of 1-2 msec). This may be what I need. If there is one product there are likely others.

View 5 Replies View Related - Local Static Variables In Timer.Tick Event (Stopping A Timer)

Jul 9, 2009

I have a timer on a page in ASP.NET.

After a certain period of time elapses, I want to disable the timer.

I want to put a static variable in the timers tick event that will track how many seconds have elapsed.

My question is, will this work?

If user X and Y are viewing the page will they both have separate local static variables?

What is the best method of shutting down an ASP.NET timer after a certain elapsed time?

View 1 Replies View Related

Synchronize The Timer Event So That The Timer Executes From The Background Worker Thread?

Apr 23, 2009

I have a windows application that need to process som quite time consuming jobs. In my first try i did all processing under
the form thread. The result was bad response and update of the form due to the heavy jobs.To get around the problem with bad response from the form i created a new class "processing" where i put all the data processing. Then i instanciated a background worker where i in the "doWork" sub created a new instance of "processing".The "processing" class creates a timer from system.timer, and the timer drives the processing.On the Timer event Elapsed the timer starts a new thread from the thread pool.

My problem is now when i want to asynchronously close the background worker (with the corresponding function call what ever it is called ...) there is still a timer thread out there that causes exceptions for me.

1. How can i close my background worker and at the same time have the timer to be stopped?

2. Is there a way to synchronize the timer event so that the timer executes from the background worker thread?

3. Is there a better approach for me to adapt?

View 3 Replies View Related

Create An Array Of Timer - Raise The Tick Event For A Particular Timer?

Jan 11, 2011

I want to create an array of timer in My problem is that how will i raise the tick event for a particular timer, say mytimer(x).tick and inside the tick event there is also a button, say mybutton(x) which changes location every interval. for example:

public class blah
dim mybuttons(20) as button
dim mytimer(20) as timer
private sub form_load(....) handles me.load
for x as integer = 0 to 20


i dont know what to do next, all i want is to pass the button mybuttons(x) to mytimer(x) tick event, in which their index number are the same. i want to create one timer per button. how to do that? please help me and post example codes. i've researched the net but i cant understand passing variables, addhandlers, etc. i'm just new to programming object oriented.

View 6 Replies View Related

VS 2010 Incorporate The Timer So Once A Page Loads The Timer Activates?

Jul 4, 2011

How can I incorporate the timer so once a page loads the timer activates, waits a few seconds then I tell my program what to do next.I tried this code but it didnt work:

Timer1.Interval = 5000
Timer1.Enabled = True


View 3 Replies View Related

Timer And 64bit Processor - Timer That Doesn't Work?

Sep 30, 2010

Everything is nice and dandy on my pc, then I compile, move it to its final destination and I doesn't work! At first I thought it was a OS problem, but both machines has win7, I then thought it was a compilation problem, installed visual studio on the other pc, recompiled still with no luck, then it dawned on me, may it be a problem of 32bit vs 64bit?The piece of code is this:[code]....

By the way is not a problem of mouse_event, is the timer that doesn't work

View 2 Replies View Related

Timer Control In VB - When I Click Outside Of The Form, The Timer Stops?

Mar 24, 2009

I have a timer in and it's interval is 1000ms ,. i have placed in it's timer_tick event a code that will print screen the screen and save it to a database.The problem is when i click outside of the form, or loosing the focus of the mouse to the form containing that timer/printscreen, the timer stops. As a result the printscreen also are it's properties:

generate member = true
interval = 1000
modifiers = friend

View 1 Replies View Related

Wake PC From Sleep?

Jul 11, 2010

I currently trying to write a simple visual basic 2008 code referring to:


However, I getting an Error on: Dim wup As New WakeUPTimer.WakeUP

Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data


View 2 Replies View Related

.net - Systems.timer.timer Unwanted Multithreading?

Jul 14, 2011

I recently switched my code from using the windows.forms.timer to the systems.timer.timer and it has resulted in a multithreading error. I'm using the timer to trigger just one event so multithreading shouldn't be an issue. To give more detail I have implemented the timer at follows:
At the top of the class I have: Private Shared timr1sec As System.Timers.Timer

When the program loads (Private Sub Test_load):
timr1sec = New System.Timers.Timer(1000)
AddHandler timr1sec.Elapsed, AddressOf OnTimedEvent

In OnTimedEvent I call several subroutines, and write some data to the screen using a ListView object.VisualExpress throws the multithreading error on the last line of this code, which is in OnTimedEvent


View 1 Replies View Related

Timer In A Thread - Routine Which Is Controlled By A Timer

Aug 13, 2010

I have a routine which is controlled by a timer. It works perfectly. The problem is that now, I need to run this routine several times, so I need to start differents threads so that my program doesn't get hung up. I've been trying to start my timer inside a thread, but it doesn't work!

View 18 Replies View Related

VB6 Create Object Of Timer Instead Of Timer Control

Nov 6, 2009

VB6 create object of timer instead of timer control

View 5 Replies View Related

Check If PC Is In Sleep Mode?

Jul 27, 2009

i want to check if the computer is in sleep mode or not...Suppose my project is in normal state..I change the state to sleep mode,I want that now when the computer wakes from sleep mode,I want that my project is in minimized state..How to check dat?

View 3 Replies View Related

Check When PC Is In Sleep Mode?

Jul 27, 2009

I want to check if the computer is in sleep mode or not...Suppose my project is in normal state..I change the state to sleep mode,I want that now when the computer wakes from sleep mode,I want that my project is in minimized state.[code]....

View 14 Replies View Related

How To Sleep Thread Of BackgroundWorker In WPF

Jul 29, 2009

I wanna sleep a second thread of BackgroundWorker. I tried to use Me.Dispatcher.Thread.Sleep(500) in DoWork event, but it fails.

View 3 Replies View Related

Is There A Sleep Method In VB 2003

Aug 20, 2009

Is there a sleep method in

View 5 Replies View Related

Prevent Windows From Going To Sleep?

Feb 8, 2010

I wish to prevent windows from going to sleep while my program is running.

I did allot of searching and found in MSDN the "SetThreadExecutionState" but could not find a way to make it work.

example code for preventing the sleep?

I am using windows 7 and vb 2008.

View 14 Replies View Related

Copyrights 2005-15, All rights reserved