473,399 Members | 3,106 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Try Catch Error Handling

================================================== ===============
How do I use Try Catch error handling when a timer is involved?

If I preform the preciduer below and I get an error I revive
50,000,000,000,000,000, messageboxes..
example 1;
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button4.Click
Try
If Label13.Text = ("some text") = False Then
Button3.BackColor = System.Drawing.Color.FromArgb(CType(224,
Byte), CType(224, Byte), CType(224, Byte))
Button3.Text = ("some more text")
Timer5.Enabled = True '<<<<<<<<<<<< say this timer is error
free!
Timer6.Enabled = True '<<<<<<<<<<<< say this timer ha an error
and it kicks an exception error!
End If
Panel1.Visible = False
Catch ex As Exception
Dim proc As System.Diagnostics.Process
Dim pList() As Process
pList = Process.GetProcessesByName("some app")
For Each proc In pList
Dim resp As MsgBoxResult
resp = MsgBox("Error 0020 some error, Do you wish to Exit "
& proc.ProcessName & "?", _
MsgBoxStyle.YesNo, "app error")
If resp = MsgBoxResult.Yes Then
proc.Kill()
If resp = MsgBoxResult.No Then
Application.DoEvents()
End If
End If
Next
Exit Try
Finally
End Try
End Sub

If an exception error happens with the above code I get
50,0000,0000000000000,00000,000,0,0,00,,0,0,0,0,0, 0,0,+1 messageboxes!
This next example works fine but it seames to me that it's overkill to have
too write my code twice, is ther another way to acoumplish the samething if
someone clickes NO???
Example 2;
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button4.Click
Try
If Label13.Text = ("some text") = False Then
Button3.BackColor = System.Drawing.Color.FromArgb(CType(224,
Byte), CType(224, Byte), CType(224, Byte))
Button3.Text = ("some more text")
Timer5.Enabled = True '<<<<<<<<<<<< say this timer is error
free!
Timer6.Enabled = True '<<<<<<<<<<<< say this timer ha an error
and it kicks an exception error!
End If
Panel1.Visible = False
Catch ex As Exception
Timer5.Enabled = False
Timer6.Enabled = False
Dim proc As System.Diagnostics.Process
Dim pList() As Process
pList = Process.GetProcessesByName("some app")
For Each proc In pList
Dim resp As MsgBoxResult
resp = MsgBox("Error 0020 some error, Do you wish to Exit "
& proc.ProcessName & "?", _
MsgBoxStyle.YesNo, "app error")
If resp = MsgBoxResult.Yes Then
proc.Kill()
If resp = MsgBoxResult.No Then
Application.DoEvents()
If Label13.Text = ("some text") = False Then
Button3.BackColor = System.Drawing.Color.FromArgb(CType(224,
Byte), CType(224, Byte), CType(224, Byte))
Button3.Text = ("some more text")
Timer5.Enabled = True '<<<<<<<<<<<< say this timer is error
free!
Timer6.Enabled = True '<<<<<<<<<<<< say this timer ha an error
and it kicks an exception error!
End If
Panel1.Visible = False
End If
End If
Next
Exit Try
Finally
End Try
End Sub
================================================== ==========================
=

Nov 20 '05 #1
8 1668
"CarpetMnuncher!" <Ba*@mail.com> schrieb
Timer6.Enabled = True '<<<<<<<<<<<< say this timer ha an
error
and it kicks an exception error!

Where does the exception occur? In the event handler of the Timer? Is it a
System.Windows.Forms.Timer or a System.Timers.Timer?
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #2
Cor
Hi CarpetMnucher,

If I look at your code I get the idea that you don't use use the try, catch
end try to prevent unpredictable errors. But to catch program errors.

I cannot see how a timer process can make an error in an other way that that
there is an error in the code (or the computer is damaged and than will the
try and error block also not work).

Just a thought

Cor

Nov 20 '05 #3
Hello,
Here are your reply's

ARMIN
#1,,,,Where does the exception occur? In the event handler of the Timer? Is
it a
System.Windows.Forms.Timer or a System.Timers.Timer?
Answer = If an error occurs in the event handler of the timer.
My application uses both System.Windows.Forms.Timer-s, and
System.Timers.Timer-s.

COR
#2,,,,I cannot see how a timer process can make an error in an other way
that that
there is an error in the code (or the computer is damaged and than will the
try and error block also not work).
Answer= I agree, I think I'm attempting to how would you say "over-code my
code" here.

Form ME,
Now I'm Pissed I used try catch wrong = that sucks, I did the same thing to
about 40,000 thousand pulse events which = about 200,0000 hundred thousand
lines of code which = 381 windows forms, not incliding all the modules and
ouher stuff, I think I will grab a new pack of smokes and make a hole pot
of coffee for this task looks like another sleepless night for me man = Ha,
ha, ha, cry.

"Armin Zingler" <az*******@freenet.de> wrote in message
news:OK**************@TK2MSFTNGP10.phx.gbl...
"CarpetMnuncher!" <Ba*@mail.com> schrieb
Timer6.Enabled = True '<<<<<<<<<<<< say this timer ha an
error
and it kicks an exception error!

Where does the exception occur? In the event handler of the Timer? Is it a
System.Windows.Forms.Timer or a System.Timers.Timer?
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #4
"CarpetMnuncher!" <Ba*@mail.com> schrieb
Hello,
Here are your reply's

ARMIN
#1,,,,Where does the exception occur? In the event handler of the
Timer? Is it a
System.Windows.Forms.Timer or a System.Timers.Timer?
Answer = If an error occurs in the event handler of the timer.
Then you must put Try-Catch in the event handler.
My application uses both System.Windows.Forms.Timer-s, and
System.Timers.Timer-s.
And those mentioned (timer5, timer6) are?

Form ME,
Now I'm Pissed I used try catch wrong = that sucks, I did the same
thing to about 40,000 thousand pulse events which = about 200,0000
hundred thousand lines of code which = 381 windows forms, not
incliding all the modules and ouher stuff, I think I will grab a new
pack of smokes and make a hole pot of coffee for this task looks like
another sleepless night for me man = Ha, ha, ha, cry.


Do you see strange colors? ;-)) I understand you very well (or good?)....
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #5
I figured it out, I staled up all night "cut & Paste"-ing!
A pot of coffee, 1 pack of smokes, and a trip to the 24 hr store for a new
set of wireless mouse batteries, later I got it done and it works great.
Now I do see colors red, blue, and green dots, < I guess thats whay thay
call it .NET :))

I jest wanted to say thanks for your help !
____________________________________
"Armin Zingler" <az*******@freenet.de> wrote in message
news:eQ**************@TK2MSFTNGP10.phx.gbl...
"CarpetMnuncher!" <Ba*@mail.com> schrieb
Hello,
Here are your reply's

ARMIN
#1,,,,Where does the exception occur? In the event handler of the
Timer? Is it a
System.Windows.Forms.Timer or a System.Timers.Timer?
Answer = If an error occurs in the event handler of the timer.


Then you must put Try-Catch in the event handler.
My application uses both System.Windows.Forms.Timer-s, and
System.Timers.Timer-s.


And those mentioned (timer5, timer6) are?

Form ME,
Now I'm Pissed I used try catch wrong = that sucks, I did the same
thing to about 40,000 thousand pulse events which = about 200,0000
hundred thousand lines of code which = 381 windows forms, not
incliding all the modules and ouher stuff, I think I will grab a new
pack of smokes and make a hole pot of coffee for this task looks like
another sleepless night for me man = Ha, ha, ha, cry.


Do you see strange colors? ;-)) I understand you very well (or good?)....
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #6
"CarpetMnuncher!" <Ba*@mail.com> schrieb
I figured it out, I staled up all night "cut & Paste"-ing!
A pot of coffee, 1 pack of smokes, and a trip to the 24 hr store for
a new set of wireless mouse batteries, later I got it done and it
works great. Now I do see colors red, blue, and green dots, < I guess
thats whay thay call it .NET :))
:-)))))
I jest wanted to say thanks for your help !


Problem solved? Glad to hear.. um.. read.
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #7
Cor
Hi "CarpetMnuncher!"

I jest wanted to say thanks for your help !
____________________________________

:-((

Only Armin?

Cor
Nov 20 '05 #8
And this is why I love software development.

=)

"Armin Zingler" <az*******@freenet.de> wrote in message
news:Oo**************@TK2MSFTNGP09.phx.gbl...
"CarpetMnuncher!" <Ba*@mail.com> schrieb
I figured it out, I staled up all night "cut & Paste"-ing!
A pot of coffee, 1 pack of smokes, and a trip to the 24 hr store for
a new set of wireless mouse batteries, later I got it done and it
works great. Now I do see colors red, blue, and green dots, < I guess
thats whay thay call it .NET :))


:-)))))
I jest wanted to say thanks for your help !


Problem solved? Glad to hear.. um.. read.
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #9

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

Similar topics

4
by: Evgeny Gopengauz | last post by:
Is there something like exception handling in T-SQL? For example, how to catch an error of convertion at this sample: CREATE PROCEDURE SP @param VARCHAR(50) AS BEGIN DELCARE @var INT -- try...
7
by: Noor | last post by:
please tell the technique of centralize exception handling without try catch blocks in c#.
7
by: Dan Bass | last post by:
In a somewhat complex application, I've developed plug-in architecture and am having a problem as to when to catch general exceptions for logging purposes. In each plug-in class library, for...
37
by: clintonG | last post by:
Has somebody written any guidelines regarding how to determine when try-catch blocks should be used and where their use would or could be considered superfluous? <%= Clinton Gallagher...
23
by: VB Programmer | last post by:
Variable scope doesn't make sense to me when it comes to Try Catch Finally. Example: In order to close/dispose a db connection you have to dim the connection outside of the Try Catch Finally...
9
by: Michael MacDonald | last post by:
Does someone have a good site I can visit or explain the use of Try" and Catch foe exception/error handling. What is the logic behind this command and maybe an example would be great!!!! Mike_Mac...
4
by: DavideR | last post by:
I have converted a large vb6 program with an add-in that for every routine gimme the error handling: the add-in adds one line on the head of the routine "if myerrhandle then ON ERROR GOTO...
32
by: cj | last post by:
Another wish of mine. I wish there was a way in the Try Catch structure to say if there wasn't an error to do something. Like an else statement. Try Catch Else Finally. Also because I...
23
by: pigeonrandle | last post by:
Hi, Does this bit of code represent complete overkill?! try { //create a treenode TreeNode tn = new TreeNode(); //add it to a treeview tv.Nodes.Add(tn);
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...

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.