473,386 Members | 1,738 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,386 software developers and data experts.

Event identification

Hi y'all,

I posted this as an add on to another post so I thought I'd repost it here.

How do I identify an event programmatically?

Is it necessary to do a

if(e.message=="<Event description>" ) ...

to identify the particular event?

Thanx,
Bill

Nov 17 '05 #1
3 1009
web1110 <we***@comcast.net> wrote:
I posted this as an add on to another post so I thought I'd repost it here.

How do I identify an event programmatically?

Is it necessary to do a

if(e.message=="<Event description>" ) ...

to identify the particular event?


The best thing is to only subscribe events you're interested in, and
use different handlers for each of the events you want to handle
differently - that way you don't need to test in your code.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 17 '05 #2
I am not clear on how to subscribe on a particulat event. Alright, in this
case, the exception a System.ArgumentException and I can catch it. But my
question is, given a System.ArgumentException, will the message property
always be the same could there be a range of exceptions within this? I
suspect the latter, so all I can do is catch a category of exceptions and
not act on a specific exception which I may want to ignore unless I check
the message property..
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
web1110 <we***@comcast.net> wrote:
I posted this as an add on to another post so I thought I'd repost it here.
How do I identify an event programmatically?

Is it necessary to do a

if(e.message=="<Event description>" ) ...

to identify the particular event?


The best thing is to only subscribe events you're interested in, and
use different handlers for each of the events you want to handle
differently - that way you don't need to test in your code.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 17 '05 #3
web1110 <we***@comcast.net> wrote:
I am not clear on how to subscribe on a particulat event. Alright, in this
case, the exception a System.ArgumentException and I can catch it. But my
question is, given a System.ArgumentException, will the message property
always be the same could there be a range of exceptions within this? I
suspect the latter, so all I can do is catch a category of exceptions and
not act on a specific exception which I may want to ignore unless I check
the message property..


Ah, you were talking about exceptions rather than events? In that case,
I suggest you only catch the right kind of exception:

catch (ArgumentException e)
{
....
}

And no, the message of an exception won't always be the same.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 17 '05 #4

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

Similar topics

1
by: Brad H McCollum | last post by:
I've looked through many suggestions and partial examples all over this newsgroup and still am not coming up with anything that does specifically what I'm wanting to accomplish. I'm writing a VB...
5
by: Carl Ribbegaardh | last post by:
Is there any known list of compiler identification macros? I'm using VS 2003, g++ on windows, sun's cc and g++ on solaris. Is it possible to identify the compiler using macros? I'm aware of WIN32...
23
by: Roel Melchers | last post by:
My ACCESS-database contains all members of my association. When the members attend to a meeting I want to record their presence. When they enter they identify themselves by putting their finger...
8
by: frankcvc | last post by:
I created a control array at runtime using the following code. I also wanted to code the controlarray click event. My code can respond to click event but cannot identify the specific control...
5
by: Russell Smallwood | last post by:
Hello all, Why can't I wire up an event during the "Raise PostBackEvent" stage of a postback? Just in case this is the wrong question, the situation: deep in the bowls of some code-behind...
5
by: Mike | last post by:
I am relatively new to Web development and I have a pretty simple question. How do I get the web site identification information (from IIS) inside my aspx.cs? Spacifically I want the web pages...
9
by: pvsundarram | last post by:
hey, i am trying to cancel the keydown event for certain keycodes( for eg:- enter key ).But the cancelling of this event is not happening in firefox. Is there any way to cancel the event in the...
1
by: ZZyZX | last post by:
I wish to uniquely identify the below button element embedded among many other button elements in a web page and call the click event on it to automatically navigate to the next page in a sequence...
5
by: Kevin | last post by:
I want a calculated control to transfer its value to a bound field in a table. I.e. I have a calculated control named txtFinalBid that adds several fields in a table. I want that number to be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...

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.