Fred,
Am I right in thinking that it can only be a problem if the program running
between the SyncLock and End SyncLock has a possibility of recalling the
"SomeWork" sub or running another SyncLock Me.GetType somewhere.
No!
SyncLock is NOT needed if the same thread can call the SomeWork method while
the SomeWork method is executing, as that is simple recursion.
SyncLock is needed if two threads can call SomeWork for the same object, at
the same time, if SomeWork modifies that object.
SyncLock is NOT needed if SomeWork can be called for different objects and
you are encapsulating your data within an object.
SyncLock is needed when using "global" variables (Module, Shared Class, or
Shared Structure variables).
SyncLock is also needed if two threads both are calling methods, properties
or using fields on the same object, at the same time. Normally its better to
encapsulate the SyncLock internal to the object itself.
Of course there are exceptions to the above broad rules, and there may be
better locking mechanisms in System.Threading depending on what you are
trying to accomplish. Plus I may have missed one or two rules...
SyncLock is generally used to protect an object not just a single routine.
For example SomeWork may be updating a total amount, other routines that
read the total amount probably should wait until the update is finished...
To better answer your question it really depends on what the SomeWork
routine is doing, and how any shared or instance variables that SomeWork
uses are being used elsewhere.
Hope this helps
Jay