use timer in a vb.net dll -


i need wait , event within given period (30s) , timeout if time elapse. need do?

am sending command server dll, , need wait response before sending another. want implement timeout feature, why need use timer

i want use timer, don't know how use in dll.

this little piece of code illustrates why using timer represent interval of time bad idea

dim withevents mytimer new windows.forms.timer 'a timer dim stpw new stopwatch dim count long  const intervalvalue integer = 1000 'some number of ms. s/b > 10  private sub mytimer_tick(byval sender object, _                          byval e system.eventargs) handles mytimer.tick     count += 1     dim foo long = count * intervalvalue 'the interval using tick firing every intervalvalue ms.     dim bar long = stpw.elapsedmilliseconds 'the actual amount of time has passed      label1.text = foo.tostring("n0")     label2.text = bar.tostring("n0")      label3.text = (bar - foo).tostring("n0") 'show error end sub  private sub form1_shown(byval sender object, _                         byval e system.eventargs) handles me.shown      mytimer.interval = intervalvalue 'number of ms.     mytimer.start()     stpw.start()  end sub 

a better approach set timer smaller value, 1 second example, , see if elapsed time greater value looking for.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -