vb.net - Timer does not work -


I try to run a timer with my Winform application. Called not a reason to break the timer tick ( IsTimeOffsetValid ) running on function points nor stopped, and basically does nothing Below I attach a code sample.

I appreciate the help.

  Module Module1 Sub Main () Dim OutputForm new Forml7 ApplicationkRun (End Sub End as OutputForm) module  
  public class Forml7 this object personal TimerServerOffset New System.Timers.Timer Private sub Form17_Load (ByVal, ByVal e as System.EventArgs) handles Me.Load as AddHandler TimerServerOffset.Elapsed, New System.Timers.ElapsedEventHandler (AddressOf IsTimeOffsetValid) TimerServerOffset.Interval = 1 TimerServerOffset.Start () end sub Private sub IsTimeOffsetValid () MsgBox ( "IsTimeOffsetValid") end sub end class  

posted by you Apart from the errors in the code, there are other problems with the design.

Read this question:

Callback is called on a worker thread (not UI thread), so displaying a message box can be a big problem.

Then switch to a more fitting timer. If you want to do that, the input is valid in every second, go to the system.windows.form. Timer The ticker handler runs on the UI thread so you can change the UI in the handler.

After changing the interval, consider that a message box popping up every millisecond is not possible and is not user-friendly

Finally, I use the timer for it Do not suggest: just handle the changes in the input field and respond to the converted input or use the standard validation events of the WinForms control. It's very cheap (on the CPU) and will not mess with the focus.


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -