Compartir a través de


CSingleLock::Unlock

Libera el objeto de sincronización que pertenece a CSingleLock.

BOOL Unlock( ); 
BOOL Unlock( 
   LONG lCount, 
   LPLONG lPrevCount = NULL  
);

Parámetros

  • lCount
    Número de accesos a la versión. Debe ser mayor que 0. Si la cantidad especificada haría el recuento de objeto supere el máximo, el número no cambia y la función devuelve FALSO.

  • lPrevCount
    Señala una variable para recibir el número anterior del objeto de sincronización. si NULL, el recuento anterior no se devuelve.

Valor devuelto

Distinto de cero si la función es correcta; si no 0.

Comentarios

Esta función se llama al destructor de los entity_CSingleLock.

Si necesita liberar más de un recuento de acceso de un semáforo, use el segundo formulario de Unlock y especifique el número de accesos a la versión.

Ejemplo

// m_Mutex is a data member (of type CMutex)
// of an existing class that implements the resource being shared.

// Relate the synchronization object (m_Mutex) with
// our CSingleLock object. 
CSingleLock singleLock(&m_Mutex);

// Attempt to lock the shared resource
if (singleLock.Lock(100))    // Wait 100 ms...
{
    // We were able to lock the resource;
    // we may now work with the data associated with the mutex...

    // Now that we are finished, unlock the resource for others.
    singleLock.Unlock();
}

Requisitos

encabezado: afxmt.h

Vea también

Referencia

CSingleLock Class

Gráfico de jerarquías