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 / C++ / MFC
  4. Can I raise Exception in one thread and handle it in another?

Can I raise Exception in one thread and handle it in another?

Scheduled Pinned Locked Moved C / C++ / MFC
csharpvisual-studioquestion
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.
  • C Offline
    C Offline
    chilituna
    wrote on last edited by
    #1

    Hi, I am a bit curious.. Can I raise exception (with RaiseException()?) and get it handled in another thread?? This is needed for operation stop-functionality. I thought it would be nice to have one dialog where is stop button, and it stops whatever the main thread is doing.. Does anybody know how it is done in Visual Studio? It's possible to freeze the debugged process anytime, when debugging.

    J D M 3 Replies Last reply
    0
    • C chilituna

      Hi, I am a bit curious.. Can I raise exception (with RaiseException()?) and get it handled in another thread?? This is needed for operation stop-functionality. I thought it would be nice to have one dialog where is stop button, and it stops whatever the main thread is doing.. Does anybody know how it is done in Visual Studio? It's possible to freeze the debugged process anytime, when debugging.

      J Offline
      J Offline
      James R Twine
      wrote on last edited by
      #2

      I do not think that the exception will cross threads.  I would suggest using a Win32 Event object, because it can be seen by multiple threads, and signal it in one thread to indicate the other to stop processing.    Peace!

      -=- James
      Please rate this message - let me know if I helped or not! * * * If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
      Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
      See DeleteFXPFiles

      1 Reply Last reply
      0
      • C chilituna

        Hi, I am a bit curious.. Can I raise exception (with RaiseException()?) and get it handled in another thread?? This is needed for operation stop-functionality. I thought it would be nice to have one dialog where is stop button, and it stops whatever the main thread is doing.. Does anybody know how it is done in Visual Studio? It's possible to freeze the debugged process anytime, when debugging.

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #3

        chilituna wrote:

        I thought it would be nice to have one dialog where is stop button, and it stops whatever the main thread is doing..

        Is the dialog modal?


        "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

        "Judge not by the eye but by the heart." - Native American Proverb

        1 Reply Last reply
        0
        • C chilituna

          Hi, I am a bit curious.. Can I raise exception (with RaiseException()?) and get it handled in another thread?? This is needed for operation stop-functionality. I thought it would be nice to have one dialog where is stop button, and it stops whatever the main thread is doing.. Does anybody know how it is done in Visual Studio? It's possible to freeze the debugged process anytime, when debugging.

          M Offline
          M Offline
          Michael Dunn
          wrote on last edited by
          #4

          chilituna wrote:

          Can I raise Exception in one thread and handle it in another?

          No, the handler has to be somewhere in the throwing thread's call stack.

          --Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ");

          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