How do I get the a timedate value to the ws timer clock ?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi;

I am trying to give my CPU some relief from comparing a group of values to
now() while looping through an array. I tried using the windows.system.timer
but i have been unable to find the correct interval that will allow a match
as in
compare("08/14/2006 10:30:00 AM", Now) = 0. in the tick event.

I tired looking into the server oriented timer but it only has an elasped
event and that's not what I need.

Do i even need a time to pause my CPU access ? Could I just not use a DO
Loop to
pause the iterations of my For next ?

Thanks
 
Gordon,

First a question, do you have any reason to use the windows.system timer
instead of the simple windows.forms.timer?

In other words, is this timer used in a simple single threaded forms
application or in another way?

Cor
 
Gordon,

Reading your message again,

Probably the simple
\\\
Threading.Thread.Sleep(TheRelieveTimeInMilliSeconds)
///
Gives what you want to do.

I hope this helps,

Cor
 
Gordon,
It sounds like you want to use Sleep as Cor suggests:

Threading.Thread.Sleep(TheRelieveTimeInMilliSeconds)

To find TheRelieveTimeInMilliSeconds you can use simple subtraction.

Dim theDate As Date = #8/14/2006 10:30:00 AM#

Dim theTimeSpan As TimeSpan = theDate - DateTime.Now

System.Threading.Thread.Sleep(theTimeSpan)

NOTE: Sleeps accepts either a TimeSpan or a Integer. I find using the
TimeSpan above more "convenient".

If you need a Timer, and want to to start at a specific time, you can use
System.Threading.Timer, where you pass theTimeSPan from above to the dueTime
on the System.Threading.Timer constructor.

Dim timer As New System.Threading.Timer(AddressOf OnElapsed,
Nothing, theTimeSpan, period)

If you set the period parameter to -1 milliseconds the event will fire once.

--
Hope this helps
Jay B. Harlow [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net


| Hi;
|
| I am trying to give my CPU some relief from comparing a group of values to
| now() while looping through an array. I tried using the
windows.system.timer
| but i have been unable to find the correct interval that will allow a
match
| as in
| compare("08/14/2006 10:30:00 AM", Now) = 0. in the tick event.
|
| I tired looking into the server oriented timer but it only has an elasped
| event and that's not what I need.
|
| Do i even need a time to pause my CPU access ? Could I just not use a DO
| Loop to
| pause the iterations of my For next ?
|
| Thanks
|
| --
| Gordon
 
Back
Top