winapi - Win32 Mutex not waiting -
I am creating an application that implements inter process communication. For this purpose, I have set up a shared buffer, which works fine. Now, I need to get data for receiving data (written in C ++) (written in FreePascal / Lasers) When data should be read.
I was trying to use a mute x for this purpose. I do not have much experience with Windows API programming.
Therefore, my problem is in the free Pascal code below, Mute X will not wait. I can call the TMutex.Wait () function, it does not return any errors or anything, but it just will not wait.
Constructor TMutex.Create (sName: AnsiString); Start
& nbsp; & Nbsp; SName: = 'local \ mute x' + sName;
& nbsp; & Nbsp; HMutex: = CreateMutexA (
& nbsp; & nbsp; & nbsp; blue, // default access - & nbsp; & nbsp; & nbsp; & nbsp; ; & Nbsp; & nbsp; & nbsp; True, // was not initially owned & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;; PChar SNAME)); // Named Mute X & nbsp; & Nbsp; If hMutex = 0 then & nbsp; & Nbsp; Start & nbsp; & Nbsp; & Nbsp; & Nbsp; Increase the exception. Create ('Mutex creation failed');
& Nbsp; & Nbsp; the ending;
End;
Destructor TMutex.Destroy;
& nbsp ;; CloseHandle (hMutex);
End;
TMutex.Wait processing;
Start & nbsp; & Nbsp; If (WaitMarks, INFINITE) & lt;> 0) then ShowMessage ('Debug: Waiting return');
end;
TMutex.Post;
& nbsp; & Nbsp; Release Mutux (hMutex);
End;
It seems that your problem is here:
< Pre> is true, // is not initially owned
Your past things - the true meaning is that it is initially owned, so it will have to wait immediately.
Comments
Post a Comment