procedure TSyncManager.RemoveThread(ThreadSync : TThreadSync);
var
lpInfo : TSyncInfo;
begin
// Enter critical section
EnterCriticalSection(FThreadLock);
// Resource protection
try
// Find the info using the base thread id
lpInfo := FindSyncInfo(ThreadSync.SyncBaseTID);
// Check assignment
if Assigned(lpInfo) then
PostMessage(lpInfo.FThreadWindow, CM_DESTROYWINDOW, 0,
// Longint(lpInfo)); // old version
LPARAM(lpInfo)); // my version
finally
// Leave the critical section
LeaveCriticalSection(FThreadLock);
end;
end;
procedure TSyncManager.Synchronize(ThreadSync : TThreadSync);
var
lpInfo : TSyncInfo;
begin
// Find the info using the base thread id
lpInfo := FindSyncInfo(ThreadSync.SyncBaseTID);
// Check assignment, send message to thread window
if Assigned(lpInfo) then
// SendMessage(lpInfo.FThreadWindow, CM_EXECPROC, 0, Longint(ThreadSync)); // old version
SendMessage(lpInfo.FThreadWindow, CM_EXECPROC, 0, LPARAM(ThreadSync)); // my version
end;
Named pipe failure, multithreading and asynchronous I/O
in Windows API
Posted
I Think I found two bugs in 64 bit mode:
procedure TSyncManager.RemoveThread(ThreadSync : TThreadSync); var lpInfo : TSyncInfo; begin // Enter critical section EnterCriticalSection(FThreadLock); // Resource protection try // Find the info using the base thread id lpInfo := FindSyncInfo(ThreadSync.SyncBaseTID); // Check assignment if Assigned(lpInfo) then PostMessage(lpInfo.FThreadWindow, CM_DESTROYWINDOW, 0, // Longint(lpInfo)); // old version LPARAM(lpInfo)); // my version finally // Leave the critical section LeaveCriticalSection(FThreadLock); end; end; procedure TSyncManager.Synchronize(ThreadSync : TThreadSync); var lpInfo : TSyncInfo; begin // Find the info using the base thread id lpInfo := FindSyncInfo(ThreadSync.SyncBaseTID); // Check assignment, send message to thread window if Assigned(lpInfo) then // SendMessage(lpInfo.FThreadWindow, CM_EXECPROC, 0, Longint(ThreadSync)); // old version SendMessage(lpInfo.FThreadWindow, CM_EXECPROC, 0, LPARAM(ThreadSync)); // my version end;
Carsten