Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. throw exception "into" another thread

throw exception "into" another thread

Scheduled Pinned Locked Moved C#
question
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Rupel
    wrote on last edited by
    #1

    hi, i have the well-known worker-thread doing some computations in the background. when there is an exception raised in this thread, it simply vanishes into hyperspace. X| is there any standard-way of handling exception thrown by the worker-thread in the calling thread? i could do numorous nasty hacks and workaround, but i don't know any "nice" way :-O thx for ideas. :wq

    P J P 3 Replies Last reply
    0
    • R Rupel

      hi, i have the well-known worker-thread doing some computations in the background. when there is an exception raised in this thread, it simply vanishes into hyperspace. X| is there any standard-way of handling exception thrown by the worker-thread in the calling thread? i could do numorous nasty hacks and workaround, but i don't know any "nice" way :-O thx for ideas. :wq

      P Offline
      P Offline
      Paul Riley
      wrote on last edited by
      #2

      Best idea I can think of is to wrap it all in a huge try block and raise an event with the details of the exception in it. Events are designed to be caught, exceptions aren't. Paul

      1 Reply Last reply
      0
      • R Rupel

        hi, i have the well-known worker-thread doing some computations in the background. when there is an exception raised in this thread, it simply vanishes into hyperspace. X| is there any standard-way of handling exception thrown by the worker-thread in the calling thread? i could do numorous nasty hacks and workaround, but i don't know any "nice" way :-O thx for ideas. :wq

        J Offline
        J Offline
        James T Johnson
        wrote on last edited by
        #3

        You can attach an event handler to the current AppDomain's UnhandledException event. This won't filter exceptions from that particular thread but it at least you can handle that exception.

        James Sig code stolen from David Wulff

        1 Reply Last reply
        0
        • R Rupel

          hi, i have the well-known worker-thread doing some computations in the background. when there is an exception raised in this thread, it simply vanishes into hyperspace. X| is there any standard-way of handling exception thrown by the worker-thread in the calling thread? i could do numorous nasty hacks and workaround, but i don't know any "nice" way :-O thx for ideas. :wq

          P Offline
          P Offline
          Philip Fitzsimons
          wrote on last edited by
          #4

          try using a singleton to handle the exception...


          "When the only tool you have is a hammer, a sore thumb you will have."

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups