application.lock

Z

zorro

Hello there,

To lock or not to lock, that is my question...

I have an arrayList in my application object.
The arrayList contains objects of a class that I defined.
I have my own mechanisms that ensure that only one user at
a time can modify a given object's properties, but another user
could modify another object's properties at the same time
(I want that to be possible). At no time are objects removed
from or added to the arrayList so the list itself stays intact.
Do I need to lock? Concretely:

''''''''''''''''''''''
' in global.asax
dim objGame as Game ' class defined elsewhere
dim games as arraylist

for i = 0 to x
objGame = new Game()
games.add(objGame)
next

application("games") = games

'''''''''''''''''''''
' on some page i extract a game from the arrayList and modify the gameStatus

dim objGame as game = getGame(someGameId, ctype(application("games"),arrayList))
objGame.setStatus("started")

''''''''''''''''''''''''

My own mechanisms prevent objGame from being accessed by
more than one user at a time. But other users can access other games.
Is it necessary to write
application.lock
dim objGame as game = getGame(gameId, ctype(application("games"),arrayList))
objGame.setStatus("started")
application.unlock

??
 
N

Natty Gur

Hi,

1) Lock method locks access to an HttpApplicationState therefore any
other session can't use any data in application state. that not what you
after .... this mechanism exist to make programmer life easier. if you
already implement synchronization in your class you don't need to use
application.lock.

2) I strongly recommend you to follow design patterns (such as MVC) and
to separate model classes from visualization layer.

Natty Gur[MVP]

blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)58-888377


*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,816
Latest member
SapanaCarpetStudio

Latest Threads

Top