473,405 Members | 2,415 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

application.lock

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

??
Nov 18 '05 #1
2 1527
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!
Nov 18 '05 #2
Ok thanks.
Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: J. Baute | last post by:
I'm caching data in the Application object to speed up certain pages on a website The main reason is that the retrieval of this data takes quite a while (a few seconds) and fetching the same data...
10
by: florian | last post by:
Hi, we have a contention problem because of an application which tries to insert a duplicate row in a table with primary key. This insert fails of course but the locks are not released within...
4
by: Eidolon | last post by:
Quick question about Application.Lock()... When you lock the application, does it still allow read access, or does it deny read as well as write? thanks in advance, - Aaron.
5
by: Homer J. Simpson | last post by:
Hi, Any idea to get the -REAL- number of active users -WITHOUT- this kind of code ? ---------------------------------------------------------------------------- --------- Sub Session_OnStart...
4
by: John Cosmas | last post by:
I need to execute some threads that load items into my APPLICATION object. I haven't figured out how to do that when I fire off a thread on a page, that takes its time and loads data into the...
5
by: Jennifer.Berube | last post by:
What is it exactly that makes application.lock such a bad thing? I just need a better explanation or link to a resource desribing it's downfall.
4
by: Dave | last post by:
I have a global.asax file with Application_Start defined and create some static data there and in another module used in the asp.net application and I realize that static data is shared amongst...
0
by: rkumar4acc | last post by:
Hi, We are encountering frequent deadlock- timout issues in QA Databases.Further looking into the lock snapshot, it seems that there is an agentID with appl hande ID as 0 and also we are not able...
6
by: DaveRook | last post by:
Hi I have some code from a friend and I don't understand why they have used the application lock feature! I understand this produces a random quote, but can some one explain to me what happens...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.