Utility components CustomLock object
For overview information and ClassID/ProgID of the classes see the newObjects collection overview 

CustomLock object implements critical section lock that can be used in the applications. It is mostly needed in multithreaded applications for synchronization. In ASP it can be put in the Application or Session and can be used to serialize access to some shared resource - such as text file and so on.

Methods:

method.gif (107 bytes) Lock() - Locks the object. The next call to this member will suspend until the Unlock method is not called.

MIDL definition:

[id(1), helpstring("method Lock")] HRESULT Lock();
method.gif (107 bytes) Unlock - Unlocks the object. One of the pending Lock calls will proceed (if any). 

MIDL definition:

[id(2), helpstring("method Unlock")] HRESULT Unlock();

 

 Remarks:

Using text files in ASP applications can be a good alternative to the DB usage in some cases. But in that case developer should take care about serialization of the access to the file - this component can help in doing so.

There are many specific scripting hosts that support multiply threads. Synchronization in such a hosts is extremely important and if the host has not enough instruments for the purpose then CustomLock can help to the scripters to synchronize access to the shared resources.

In C++ this class is not very useful unless the C++ part of the code does not need synchronization over an object shared with the script part of the application. In that case C++ developer needs to implement some kind of synchronization and CustomLock can be used for it.

newObjects Copyright 2001-2005 newObjects [ ]