07.03.2013 Views

Multithreading Multi-Threaded Programming

Multithreading Multi-Threaded Programming

Multithreading Multi-Threaded Programming

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Example of using Win32 Mutex Handle<br />

46<br />

HANDLE g_Mutex;<br />

DWORD dwWaitResult;<br />

// Create a mutex with initial owner.<br />

g_Mutex = CreateMutex( NULL, TRUE, "MutexToProtectDatabase");<br />

// Wait for ownership<br />

dwWaitResult = WaitForSingleObject( g_Mutex, 5000L);<br />

….<br />

ReleaseMutex(g_Mutex)); // Release Mutex<br />

Advanced Windows Network <strong>Programming</strong><br />

11/11/12

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!