MOTOBIT.COM - ASP upload, IIS utility Lock Method of Dictionary class

Method | Member of  Multi.Dictionary | Changes | Purchase | Download

Description

The Lock method blocks other clients from modifying the variables stored in the Dictionary object, ensuring that only one thread at a time can alter or access the dictionary variables.

Syntax

Dictionary.Lock ([HoldLock as Long = Infinite (-1)], [WaitForUnlock as Long = Infinite (-1)])
 

Where Type Optional Default Description
 HoldLock  Long  yes  Infinite (-1)  The time [ms] for which the dictionary lock is held 
 WaitForUnlock  Long  yes  Infinite (-1)  The time [ms] to wait for unlock 

Remarks

Version 1.1.5 solves problem with COM+ application called from within different processes - COM+ can call Lock/Unlock pair from different COM+ threads of one calling process now.
Version 1.1.6 adds timeout parameters for the Lock method. This is useful to solve problems with errors.

dic.Lock
'some code working with dictionary
dic.Unlock

You have to be sure that both Lock/Unlock methods are called. If you did not call Unlock method - usually for runtime error in 'some code' - this construction will hang in singlethread/multithreaded/multiprocess environment.
So you can use HoldLock parameter to hold the lock only some time and unlock the dictionary after the specified time, even the method Unlock was not called.

See also

Dictionary.Connect, Dictionary.Unlock, Dictionary.LockDuration

Other links for Lock

Methods of Dictionary class

Add, Connect, Disconnect, Exists, Load, Lock, Remove, RemoveAll, RemoveDictionary, Save, Unlock

Properties of Dictionary class

CompareMode, Count, Dictionaries, Item, Items, ItemsCount, Key, Keys, KeysCount, LockDuration, Name, RefCounter, UniqueKeys

Multi.Dictionary

Free threaded dictionary object. Lets you work with unique/non-unique keys, any VARIANT values and connect to other dictionary in the same process.
     Dictionary is a COM class specially designed as a free-threaded dictionary in Application scope of ASP/ASP.Net pages. It also works with script other engines in VB Script and JScript (ASP,ASP.Net, WSH, CHM, HTA), VB Net, Visual basic (VBA - VB 5, VB 6, Word, Excel, Access, …), C#, J#, C++, ASP, ASP.Net, Delphi and with T-SQL OLE functions - see Use ByteArray object article. You can also use the object in other programming environments with COM support, such is PowerBuilder.
     Source code for Dictionary is available within distribution license, please see License page for Multi Dictionary or License page for ASP file upload and ScriptUtilities.

Multi

Free-threaded (multithreaded) dictionary object. Lets you work with unique/non-unique keys in VBScript and JScript envinronment (share application/session variables in ASP) or any other programming language. You can share dictionary variables between processes or computers, you can save or restore dictionary variables to a disk, work with keys using regular expression and more.

© 1996 - 2009 Antonin Foller, Motobit Software | About, Contacts | e-mail: info@pstruh.cz


Other Motobit links:   IISTracer, real-time IIS monitor   ASP file upload - upload files to ASP. 
ActiveX/VBSScript registry editor  ActiveX NT User account manager  Export MDB/DBF from ASP Active LogFile  Email export  ActiveX/ASP Scripting Dictionary object