General information
Category:
Coding, syntax & commands
Environment versions
Network:
Windows 2008 Server
>>a bit unclear, as vfp is single threaded. Are you talking semaphores or MTA/STA apartment ?
>
>Semaphore approach but not related to data. SyncLock allows to lock at the code level until the lock is released, thus in a MTA apartment. The goal is to make sure that two instance of the same EXE cannot collide on processing the same file.
still not totally clear at this end what the exact problem is ;-)
Greg already pointed you to Mutex in dotnet, AFAIR there are pure WinAPI functions for using them, so no need for a dotnet-bridge. Also Semaphore WinAPI functions, if you decide that is the way to go, and your mentioning multiple instances of an exe rules out things like critical section. Doing this with COM STA might be a way if object status has to be single instance.
But for dumb file processing with [1..n] workers I usually split the task into worker(s) filling a table with [file location, status[ ,taskneeded][,priority]] structure and multiple workers finding those records where status is not in [done, workingstepX] and use normal multiuser record locking strategies to reflect each records/files work status. Allows re-ordering into LIFO, FIFO or task specific order of the task list stack if there is a need with the priority column and multiple stages via updating taskneeded column. And usually processing files is usually so much slower that the overhead for the synch table is negligable, the approach works across process and tasks, and is easily enhanced with bulletproofing via timestamps, machine and process ID's and so on.
View the tasks to be done as data ;-)
YMMV
thomas
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only