473,772 Members | 2,292 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

exceptions in timer dependent class

I have Class1 which performs some data calculations on
System.Timers.T imer.Elapsed event.

Public Class Class1
Private WithEvents tmrReadSerialDa ta As New
System.Timers.T imer

Public Sub New()
tmrReadSerialDa ta.Interval = 1000
End Sub

Public Sub StartIt()
tmrReadSerialDa ta.Start()
End Sub

Public Sub StopIt()
tmrReadSerialDa ta.Stop()
End Sub

Private Sub tmrReadSerialDa ta_Tick(ByVal sender As
System.Object, ByVal e As System.Timers.E lapsedEventArgs )
Handles tmrReadSerialDa ta.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.C ultureInfo("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.C ultureInfo("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, tmrReadSerialDa ta_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
Nov 21 '05 #1
7 1118
Przemo,

I am curious, what is the reason you are using the C# code in your VBNet
project for conversion, while some of the the more advantage C# users would
like to have those powerfull VBNet convert methods?

Cor
Nov 21 '05 #2
Sorry, but did you help Przemo?
I can't understand you

best regards
-----Original Message-----
Przemo,

I am curious, what is the reason you are using the C# code in your VBNetproject for conversion, while some of the the more advantage C# users wouldlike to have those powerfull VBNet convert methods?

Cor
.

Nov 21 '05 #3
> Sorry, but did you help Przemo?
I can't understand you


I thought this is a newsgroup, not a kind of helpdesk.

Now I can't understand you?

Cor

Nov 21 '05 #4
Thanks for replay, but I don't nderstad.
Am I using C# code?? I am using VB.NET.
This code compiles in vb.net project with no errors.
So what did you mean?
-----Original Message-----
Przemo,

I am curious, what is the reason you are using the C# code in your VBNetproject for conversion, while some of the the more advantage C# users wouldlike to have those powerfull VBNet convert methods?

Cor
.

Nov 21 '05 #5
Przemo,
Thanks for replay, but I don't nderstad.
Am I using C# code?? I am using VB.NET.
This code compiles in vb.net project with no errors.
So what did you mean?

In that are you right, however you limit yourself in my opinion to a very
small subset. When you would do by instance this,

For i = 1 to 1000
a +=5
Next

And than ask something as why is this not efficient to a newsgroup.

It is using as well VBNet code, however most people use
a = 5*1000

So I was curious why you are doing that?

Cor

Nov 21 '05 #6
My code was only example (small peace of my Comm parsing
Class).
I didn't want to know if it is efficient or not.
I couldn't understand why this line which should cause
exception do not do it in my class.

Write if you can help.
-----Original Message-----
Przemo,
Thanks for replay, but I don't nderstad.
Am I using C# code?? I am using VB.NET.
This code compiles in vb.net project with no errors.
So what did you mean?
In that are you right, however you limit yourself in my

opinion to a verysmall subset. When you would do by instance this,

For i = 1 to 1000
a +=5
Next

And than ask something as why is this not efficient to a newsgroup.
It is using as well VBNet code, however most people use
a = 5*1000

So I was curious why you are doing that?

Cor

.

Nov 21 '05 #7
Przemo,

This throws an exception when I try this.

Private Sub Button1_Click(B yVal sender As System.Object, _
ByVal e As System.EventArg s) Handles Button1.Click
' 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.C ultureInfo("pl-PL"))
Beep()
End sub

I hope this helps?

Cor
Nov 21 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

24
2503
by: mag31 | last post by:
Is there any way to find out if a particular .net function will throw an exception without first generating the exception? I am using structured exception handling i.e. try catch finally blocks with a top level catch all for Exception. However, I would like to be able to catch most .net exceptions when they are generated. I would then be able to generate a valuable exception message and do something about it!!! Hence the question above....
9
2341
by: Gianni Mariani | last post by:
I'm involved in a new project and a new member on the team has voiced a strong opinion that we should utilize exceptions. The other members on the team indicate that they have either been burned with unmaintainable code (an so are now not using exceptions). My position is that "I can be convinced to use exceptions" and my experience was that it let to code that was (much) more difficult to debug. The team decided that we'd give...
10
1789
by: Brian Folke Seaberg | last post by:
I was recently browsing a couple of C++ books at the local bookstore. One book called throwing exceptions from constructors a "dubious practice." Another book recommended not throwing exceptions from constructors due to the fact that the destructor for the object being constructed will not be executed and that as a result any resources allocated by the constructor prior to throwing the exception will not be deallocated if the...
3
3512
by: Pietje de kort | last post by:
Hello all, I want to implement Timeout behaviour in a class of mine. When a method is called it should timeout after a few seconds. To do this I've built a System.Threading.Timer that calls a delegate method after x milli's, the called delegate throws an exception indicating timeout. The big problem is my code will not catch the thrown exception because it
22
2740
by: Drew | last post by:
How do I know which exceptions are thrown by certain methods? For example, reading a file might throw an IO Exception, etc. In Java, the compiler won't even let you compile unless you put your code in try/catch blocks but the C# compiler doesn't seem to mind? I am particularly interested in what Exceptions are thrown by HttpWebResponse.
2
2550
by: Sam Miller | last post by:
Normally the debugger (visual studio .net environment) is good at pointing out the line of code that caused an exception.... except when that code is executed as part of a timer handler. In the case of the code below the exception is handled by a little dialog that tries to tell me how to switch on jitDebugging. (which, if I am doing it correctly doesn't seem to help). All three options are checked under...
0
1339
by: brunft | last post by:
I was testing this with .NET Framework 2.0. Exceptions in the Elapsed event handler of a System.Timers.Timer are ignored, they are not handled by the runtime and not reported (when running outside of VS.NET) either. Ther Timer continues as if nothing happened. Is this the desired behaviour, because this would have very negative impact on analysis of unexpected errors? Am i missing any design directives concerining the exception handling...
5
2814
by: Jakub Moskal | last post by:
Hi, I want to write a benchmark that will measure performance of several different algorithms for the same problem. There is a set time bound though, the algorithm cannot run longer than n minutes. Here is what the main program would do: initializeVariables(); try
8
2348
by: sip.address | last post by:
Hello, I'm trying to find some existing (and simple if possible) timer queue implementation. Does anybody know a simple skeleton to use as example? I just need to send simple (relative) timeouts. Thought about some possibilities but would prefer to use something already tested. Thanksç
0
9621
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10106
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10039
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9914
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7461
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6716
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5355
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5484
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4009
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.