timer question

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

Guest

hey all,

if i have a timer program that ticks every 1/100th of a second and it just
checks a variable status would that be a huge hit on the performance of the
system or whatever indicator the timer would affect?

just curious,
rodchar
 
appreciate it.

Chris Calzaretta said:
take a look at

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/dotnetperftechs.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/dotnetperftips.asp

I would say yes that is going to cost you .
I would say not minor but not major So somewhere inbetween there

I mean your hitting it every 1/100 of a sec to check a variable

Why not raise an event when the variable changes

meaning
this might require a code change pritty big but would get rid of timer
Public Class Class1
Public WithEvents str As New StringHelper.StringHelper
Public Sub testHelper()
str.SetString("bla")
MsgBox(str.GetString & " Property Return")
End Sub
Public Sub HandleHelperEvent(ByVal ChangedToWhat As String) Handles
str.StringChanged
MsgBox(ChangedToWhat & " This is the event that will be fired on change")
End Sub
End Class
Namespace StringHelper
Public Class StringHelper
Private str As String
Public Event StringChanged(ByVal strChanged As String)
Public Sub SetString(ByVal strInput As String)
Try
str = strInput
RaiseEvent StringChanged(strInput)
Catch ex As Exception
End Try
End Sub
Public Function GetString() As String
GetString = str
End Function
Public Sub New()
str = ""
End Sub
End Class
End Namespace


So now when you set your variable you raise the event instead of the timer

I just try to stay away from timers
If you dont get the file along with the post email me
(e-mail address removed) The file should just be class1.vb. the same code
is posted above. I do not know if you can post files in newsgroups never
tryed.



Another thing you might want to look in to is to add a handler to your
variable. I do not know if this is possible but I think it is.
I think that you variable might need to be an object for this to be
possible.

If you do add a handler to a string please post that code. I would like to
see how it is done.

read up on the addhandler method

Chris
 
Rodchar,

If it is for the use of a user, think than that for a human user 1/100 of a
second means nothing, often is one second enough where 3 seconds is the max.

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top