Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SyncLock equivalent in VFP
Message
From
21/05/2014 05:34:59
 
 
To
20/05/2014 16:19:33
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows 8.1
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01600343
Message ID:
01600372
Views:
62
This message has been marked as a message which has helped to the initial question of the thread.
>>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
Map
View

Click here to load this message in the networking platform