Click here to Skip to main content
15,918,808 members
Home / Discussions / C#
   

C#

 
GeneralRe: Installing application using C# Pin
Anonymous30-Aug-05 12:19
Anonymous30-Aug-05 12:19 
GeneralRe: Installing application using C# Pin
Guinness4Strength31-Aug-05 3:54
Guinness4Strength31-Aug-05 3:54 
QuestionQuestion about Mutex Pin
Alex Cutovoi30-Aug-05 5:17
Alex Cutovoi30-Aug-05 5:17 
AnswerRe: Question about Mutex Pin
Andy Brummer30-Aug-05 8:15
sitebuilderAndy Brummer30-Aug-05 8:15 
GeneralRe: Question about Mutex Pin
Alex Cutovoi30-Aug-05 9:25
Alex Cutovoi30-Aug-05 9:25 
GeneralRe: Question about Mutex Pin
Andy Brummer30-Aug-05 10:30
sitebuilderAndy Brummer30-Aug-05 10:30 
GeneralRe: Question about Mutex Pin
Alex Cutovoi30-Aug-05 14:17
Alex Cutovoi30-Aug-05 14:17 
GeneralRe: Question about Mutex Pin
Andy Brummer30-Aug-05 19:30
sitebuilderAndy Brummer30-Aug-05 19:30 
Imagine the mutex as a counter.
When you call WaitOne and the counter is zero then it is incremented.
If the counter is one then WaitOne enters a loop until the counter is decreased to zero and then it is incremented to 1 and the function returns.

Whenever WaitOne returns the counter is in a one state.

ReleaseMutex decrements the counter to 0.
If no threads are in WaitOne then nothing happens, but if there is a thread executing waitOne it bumps the counter back to 1 and then continues on.

That is the simplest conceptual model of a mutex. In windows terminology that is a single count semaphore which is sometimes called a mutex in other operating systems.

In windows and .net the mutex keeps track of which thread owns it. Imagine this as a counter plus a field for the threadID of the owning thread. That's how your sample worked. When each thread went out of scope all mutexes with that flag set to the threadID were released, which allowed other threads executing WaitOne to return. A thread owns the mutex when it exits from WaitOne because the mutex structure is locked and the threadID of the owner is recorded. Also through the magic of the thread scheduler, threads executing WaitOne are suspended and one is selected to wake up when releaseMutex is called rather then looping indefinitely.


I can imagine the sinking feeling one would have after ordering my book,
only to find a laughably ridiculous theory with demented logic once the book arrives - Mark McCutcheon

GeneralRe: Question about Mutex Pin
Alex Cutovoi31-Aug-05 2:53
Alex Cutovoi31-Aug-05 2:53 
GeneralRe: Question about Mutex Pin
Alex Cutovoi31-Aug-05 2:56
Alex Cutovoi31-Aug-05 2:56 
QuestionMDI Child with flicker Pin
enricrt30-Aug-05 5:15
enricrt30-Aug-05 5:15 
QuestionListView with column and images Pin
Sasuko30-Aug-05 4:36
Sasuko30-Aug-05 4:36 
AnswerRe: ListView with column and images Pin
Luis Alonso Ramos30-Aug-05 6:43
Luis Alonso Ramos30-Aug-05 6:43 
GeneralRe: ListView with column and images Pin
Sasuko30-Aug-05 7:56
Sasuko30-Aug-05 7:56 
GeneralRe: ListView with column and images Pin
Luis Alonso Ramos30-Aug-05 8:22
Luis Alonso Ramos30-Aug-05 8:22 
QuestionImage dislaying and processing in C# Pin
silka_c#30-Aug-05 4:21
silka_c#30-Aug-05 4:21 
AnswerRe: Image dislaying and processing in C# Pin
Andrew Kirillov30-Aug-05 4:59
Andrew Kirillov30-Aug-05 4:59 
QuestionRe: Image dislaying and processing in C# Pin
silka_c#31-Aug-05 0:50
silka_c#31-Aug-05 0:50 
Answer[Message Deleted] Pin
Judah Gabriel Himango30-Aug-05 5:01
sponsorJudah Gabriel Himango30-Aug-05 5:01 
AnswerRe: Image dislaying and processing in C# Pin
HumanOsc30-Aug-05 7:33
HumanOsc30-Aug-05 7:33 
QuestionJava Pin
VickyC#30-Aug-05 4:02
VickyC#30-Aug-05 4:02 
AnswerRe: Java Pin
Judah Gabriel Himango30-Aug-05 4:47
sponsorJudah Gabriel Himango30-Aug-05 4:47 
GeneralRe: Java Pin
VickyC#30-Aug-05 4:51
VickyC#30-Aug-05 4:51 
Questionadding a Palette to a Surface in DirectX Pin
silka_c#30-Aug-05 3:28
silka_c#30-Aug-05 3:28 
Questionsql connection string c# by coding Pin
bozoo30-Aug-05 2:23
bozoo30-Aug-05 2:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.