errors in threads

  • Thread starter Thread starter cs
  • Start date Start date
C

cs

Is it my idea or threads can just die when there is an error and the
exception wont show anywhere, not even when debugging on visual studio?
I have a thread that kept dieying with what I think was a null pointer
exception but I never knew it was dieying , visual studio wouldnt break at
that point or anything.
 
Hi cs,

It should stop in IDE.
For being sure that threads yields exception, put your thread code in
try/catch block and set a breakpoint into catch block.
 
cs,

You are right, VS might very well not pick it up, if it is not
monitoring the current thread of execution. Welcome to the wonderful world
of multi-threaded programming. =)

If you think there might be an issue on another thread, you can always
break at a point in that thread's execution path, and check to see what is
going on.

Also, as a general rule, you might want to propogate that error
somewhere, like in a log or something like that. This will help you with
your debug efforts.

Hope this helps.
 
Hi Nicholas,

Nicholas Paldino said:
cs,

You are right, VS might very well not pick it up, if it is not
monitoring the current thread of execution. Welcome to the wonderful world
of multi-threaded programming. =)

What do you mean by monitoring?
I suppose if the app being debugged spawns a managed thread and thread
throws an error it should be picked by IDE.
In which case vs.net won't pick up exceptions?
 
Miha Markic said:
Hi Nicholas,

message news:[email protected]...

What do you mean by monitoring?
I suppose if the app being debugged spawns a managed thread and thread
throws an error it should be picked by IDE.
In which case vs.net won't pick up exceptions?

I am unable to duplicate my error on a small example I can post but this
was what I had.
A thread that was talking to a serial port, the API I used to talk to the
serial port is probably threaded as well although I am not certain of it.
Whenver the serial API would receive something from the serial port it would
call an event, which my thread had registered a delegate for that event, on
my event handdler method I would generate another event to whatever program
had created my thread. If that event didnt have any delegates registered yet
then when calling my event it should have thrown a null pointer exception,
but instead the program would act normal like if nothing has happened
however my thread was dead and obviously no more input from the serial
connection worked.
 
Back
Top