errors in threads

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • cs

    #1

    errors in threads

    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.


  • Miha Markic

    #2
    Re: errors in threads

    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.

    --
    Miha Markic - RightHand .NET consulting & software development
    miha at rthand com

    "cs" <[rem]casolorz[rem]@hot[rem]mail.com> wrote in message
    news:ukc5M5btDH A.2932@TK2MSFTN GP11.phx.gbl...[color=blue]
    > 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.
    >
    >[/color]


    Comment

    • Nicholas Paldino [.NET/C# MVP]

      #3
      Re: errors in threads

      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.


      --
      - Nicholas Paldino [.NET/C# MVP]
      - mvp@spam.guard. caspershouse.co m

      "cs" <[rem]casolorz[rem]@hot[rem]mail.com> wrote in message
      news:ukc5M5btDH A.2932@TK2MSFTN GP11.phx.gbl...[color=blue]
      > 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.
      >
      >[/color]


      Comment

      • Miha Markic

        #4
        Re: errors in threads

        Hi Nicholas,

        "Nicholas Paldino [.NET/C# MVP]" <mvp@spam.guard .caspershouse.c om> wrote in
        message news:eW8pFMctDH A.1996@TK2MSFTN GP09.phx.gbl...[color=blue]
        > 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[/color]
        world[color=blue]
        > of multi-threaded programming. =)[/color]

        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 - DXSquad/RightHand .NET consulting & software development
        miha at rthand com


        Comment

        • cs

          #5
          Re: errors in threads


          "Miha Markic" <miha at rthand com> wrote in message
          news:OGPn8TctDH A.2088@TK2MSFTN GP09.phx.gbl...[color=blue]
          > Hi Nicholas,
          >
          > "Nicholas Paldino [.NET/C# MVP]" <mvp@spam.guard .caspershouse.c om> wrote[/color]
          in[color=blue]
          > message news:eW8pFMctDH A.1996@TK2MSFTN GP09.phx.gbl...[color=green]
          > > 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[/color]
          > world[color=green]
          > > of multi-threaded programming. =)[/color]
          >
          > 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 - DXSquad/RightHand .NET consulting & software development
          > miha at rthand com
          >
          >[/color]

          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.


          Comment

          Working...