CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2002
    Posts
    1,417

    throw in static methods

    using VC++ 2005 pro on XP 2003 server in a service program.

    I have a c++ class that contains both static and non-static methods. The static methods are callback functions that I install in database server library so that the db server can call it when errors occur. When a specific error occurs I want that static method to throw an exception to be caught by one of the non-static methods -- there may be more than one instance of the non-static methods at any given time running in different threads.

    Q: are exceptions thrown in a static method caught in try/catch blocks of all threads of the process or in only the thread in which it was thrown ? If there are two threads -- thread A and thread B, and thread A throws an exception will the catch block in thead B catch it? I hope not because it will make my life a lot easier

    Thanks

  2. #2
    Join Date
    Aug 2002
    Location
    Madrid
    Posts
    4,588

    Re: throw in static methods

    If the static function is not called by C++ code, anything can happen to the stack, so you should not throw exceptions from it.
    Get this small utility to do basic syntax highlighting in vBulletin forums (like Codeguru) easily.
    Supports C++ and VB out of the box, but can be configured for other languages.

  3. #3
    Join Date
    Jun 2002
    Posts
    1,417

    Re: throw in static methods

    Thanks for your answer -- tis not good news and not what I wanted to hear. Guess I'll have to think of some other way to handle the problem.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured