P
Przemo
I have Class1 which performs some data calculations on
System.Timers.Timer.Elapsed event.
Public Class Class1
Private WithEvents tmrReadSerialData As New
System.Timers.Timer
Public Sub New()
tmrReadSerialData.Interval = 1000
End Sub
Public Sub StartIt()
tmrReadSerialData.Start()
End Sub
Public Sub StopIt()
tmrReadSerialData.Stop()
End Sub
Private Sub tmrReadSerialData_Tick(ByVal sender As
System.Object, ByVal e As System.Timers.ElapsedEventArgs)
Handles tmrReadSerialData.Elapsed
' This line should throw an exception because of
' different culture setting (2.54 in spite of 2,54)
' but it doesn't, exits sub and Beep is not performed
Dim a As Double = Double.Parse("2.54", New
Globalization.CultureInfo("pl-PL"))
Beep
End Sub
Public Sub Test()
' Ta linia nie powoduje błędu - konwersja liczby
zapisanej w ustawieniach regionalnych USA
Dim b As Double = Double.Parse("2.54", New
Globalization.CultureInfo("en-US"))
Dim a As Double = Double.Parse("2.54")
Beep()
End Sub
End Class
When I use this object from my WinForm and click button
which performs Class1.StartIt, tmrReadSerialData_Tick
exits on line which should cause an exception but without
it!
When I place same code in my WinForm exceprion occures.
1. Is that exception caused or not?
2. Is Timer.Elapsed method run in different thread?
3. What to do to be informed of such exceptions in run-
time (program can be stopped but with normal info about
exception) - I was looking for long time what was the
reason for not executing some code after it.
Thank you
System.Timers.Timer.Elapsed event.
Public Class Class1
Private WithEvents tmrReadSerialData As New
System.Timers.Timer
Public Sub New()
tmrReadSerialData.Interval = 1000
End Sub
Public Sub StartIt()
tmrReadSerialData.Start()
End Sub
Public Sub StopIt()
tmrReadSerialData.Stop()
End Sub
Private Sub tmrReadSerialData_Tick(ByVal sender As
System.Object, ByVal e As System.Timers.ElapsedEventArgs)
Handles tmrReadSerialData.Elapsed
' This line should throw an exception because of
' different culture setting (2.54 in spite of 2,54)
' but it doesn't, exits sub and Beep is not performed
Dim a As Double = Double.Parse("2.54", New
Globalization.CultureInfo("pl-PL"))
Beep
End Sub
Public Sub Test()
' Ta linia nie powoduje błędu - konwersja liczby
zapisanej w ustawieniach regionalnych USA
Dim b As Double = Double.Parse("2.54", New
Globalization.CultureInfo("en-US"))
Dim a As Double = Double.Parse("2.54")
Beep()
End Sub
End Class
When I use this object from my WinForm and click button
which performs Class1.StartIt, tmrReadSerialData_Tick
exits on line which should cause an exception but without
it!
When I place same code in my WinForm exceprion occures.
1. Is that exception caused or not?
2. Is Timer.Elapsed method run in different thread?
3. What to do to be informed of such exceptions in run-
time (program can be stopped but with normal info about
exception) - I was looking for long time what was the
reason for not executing some code after it.
Thank you