Event identification

  • Thread starter Thread starter web1110
  • Start date Start date
W

web1110

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
 
web1110 said:
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.
 
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..
 
web1110 said:
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.
 
Back
Top