a synchronization issue - jusy for you guys
From: Amit (amit_t_at_chief.co.il)
Date: 06/06/04
- Next message: Jamie: "Re: Mediaplayer won't stop when stop command is issued 'externally'"
- Previous message: Alistair George: "BalloonHint new Dialogs etc"
- Next in thread: Jamie: "Re: a synchronization issue - jusy for you guys"
- Reply: Jamie: "Re: a synchronization issue - jusy for you guys"
- Reply: Martin Harvey (Demon Account): "Re: a synchronization issue - jusy for you guys"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 6 Jun 2004 15:46:18 +0200
i have a number of worker threads, getting a file name when created and
doing some processing with that file. some of the threads might get the same
file name, and in that case i want the first one who got to it to "tell" all
the other ones with that same file to wait untill its done. When it is done,
i want the next thread to "lock" the file for itself and "release" it to
others when it is done, and so on... the reason im using "" is because i
want all synchronization to be external, and NOT by file locking mechanizm.
i tried the following in my worker threads:
hEvent := OpenEvent(EVENT_ALL_ACCESS, True, PChar(FileName));
if hEvent = 0 then // if no one is processing that same file
right now
begin
hEvent := CreateEvent(nil, True, False, PChar(FileName));
end else // Someone is processing that file, wait until its done
begin
WaitForSingleObject(hEvent, INFINITE);
end;
..
.. { some processing }
..
SetEvent(hEvent); // Tell others im done with that file
CloseHandle(hEvent);
but it doesnt seem to work properly.
i need some kind of named critical section or something.
ideas?
- Next message: Jamie: "Re: Mediaplayer won't stop when stop command is issued 'externally'"
- Previous message: Alistair George: "BalloonHint new Dialogs etc"
- Next in thread: Jamie: "Re: a synchronization issue - jusy for you guys"
- Reply: Jamie: "Re: a synchronization issue - jusy for you guys"
- Reply: Martin Harvey (Demon Account): "Re: a synchronization issue - jusy for you guys"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|