CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2008
    Posts
    22

    using _set_se_translator in multithreaded env

    Hi All



    In my project I am trying to convert C exceptions into C++ exceptions using _set_se_translator. I am creating a multithreaded DLL in which the main app thread creates a no. of secondary threads. In the documentation I learnt that we need to register our set_translator functions for each thread.



    In my project , each thread that I create has the controlling function(i.e, the function that the thread executes) like the one below:


    UINT ControlFunC(LPVOID pvParam)
    {
    //Register translator function for each read thread
    //used to catch aynchronous exceptions
    _set_se_translator(SeTranslator);

    .....

    ....

    return 0;

    }



    Also in my main thread , I register _set_se_translator function by putting it in the constructor of the main application objec (which is dreived from CWinApp) like below:


    CMainApp::CMainApp()
    {
    // TODO: add construction code here,
    // Place all significant initialization in InitInstance
    deviceCount = 0;
    printf("\n DLL AppObj Constructor : Inside constructor");
    printf("\n DLL AppObj Constructor : About to set translator function");
    _set_se_translator(SeTranslator);
    }






    The translator function simply throws an object of a class that acts as the wrapper class. Is it ok to use the same function SeTranslator for registering my translator function for each thread.



    Also , is the way I am refistering set_se_translator for each thread, is it correct, or is there a fault?

  2. #2
    Join Date
    Nov 2003
    Posts
    1,902

    Re: using _set_se_translator in multithreaded env

    >> Is it ok to use the same function SeTranslator for registering my translator function for each thread.
    Sure. As long as your translator function simply throws a C++ object, as the documentation suggests.

    >> is it correct, or is there a fault?
    Calling _set_se_translator() on a per-thread basis is ok.

    See Reference: http://msdn.microsoft.com/en-us/libr...h5(VS.80).aspx

    gg

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