Quote Originally Posted by avi123
the thing is that I want to put in try catch and I don't know if I get to the catch if the critica section was already enter or not I guess then I can use TryEnterCriticalSection
Maybe you can do something like this:
Code:
__try
{

    */
        some code that might throw an exception
    */

    // enter a nested try-finally for your synchronized code
    __try
    {
        EnterCriticalSection(...);

        */
            more code that might throw an exception
        */
    } 
    __ finally
    {
        LeaveCriticalSection(...);
    }
}
__except(1)
{
    // handle exceptions here...
}
- petter