locked
Global Mutex RRS feed

  • Question

  • Hi,

     

    I am using the following code in a DLL that I am attaching to an application

    Code Snippet

    if( NULL == m_hMutex )

    {

    SECURITY_ATTRIBUTES sa;

    sa.nLength = sizeof(sa);

    sa.lpSecurityDescriptor = NULL;

    sa.bInheritHandle = TRUE;

    m_hMutex = CreateMutex(

    &sa, // no security attributes

    FALSE, // initially not owned

    "Global\\Avid.Mutex.Philo.Smbus"); // name of mutex

    }

     

     

     

    I have an application where I try to get access to this mutex.  Calling the following lock function (located in a function in the DLL) in the primary thread of the application works fine.  However,  when it is called from within a thread created by the application I get timeouts.

     

    Code Snippet

    unsigned long Lock(unsigned long dwMilliseconds /* = 2000 */ )

    {

     unsigned long dwResult;

    dwResult = WaitForSingleObjectEx(

    m_hMutex, // HANDLE hHandle,

    dwMilliseconds, // dwMilliseconds,

    FALSE ); // BOOL bAlertable

    return dwResult;

    }

     

     

     

     

    Thanks,

    Marty

     

    Wednesday, April 16, 2008 11:26 PM

Answers

  • I think you may find answers at this VC++ specific forum, as this forum is more for specific for architecture.

     

    Thursday, April 17, 2008 2:05 AM

All replies

  • I think you may find answers at this VC++ specific forum, as this forum is more for specific for architecture.

     

    Thursday, April 17, 2008 2:05 AM
  • Thank You.  I will try that forum.

     

    Thursday, April 17, 2008 3:16 PM