Search:
Namespaces
Discussions
.NET v1.1
Feedback
Multi-threading issues with Application scoped objects
Messages
Related Types
This message was discovered on
ASPFriends.com 'aspngarchitecture' list
.
Mark Feinholz
I want to scope an object to the application but am concerned about
possible multi-threading issues, here's the scenario:
1. I have an object Functions (type FunctionCollection), that is a
custom collection of Function objects available in the application (the
security role, the url, the link button image, etc).
2. I want to load up Functions when the App starts and keep it in
memory for the duration..
3. One of the methods on Functions is
FunctionCollection AuthorizedFunctions(Role[] roles){}.
It will return a FunctionCollection that only contains the Function
objects that are authorized given the incoming array of Role objects.
The Role object array is not managed at the application level, but
instead at the request/session level.
The AuthorizedFunction logic will create a new FunctionCollection object
and fill it with Function objects that have a RoleID that is in the
incoming list of Roles. It would not actually be creating new Function
objects for this "output" FunctionCollection object, but would instead
just be pointing to it's own collection of Function objects.
My question. If there are 100 requests all at the same time that are
trying to run this AuthorizedFunctions method, will they all end up in
the method at the same time and be overlaying eachothers local pointer
to that new FunctionCollection object that is being built? I'm not
talking about any object level state that is getting messed with by this
method, just one pointer/reference that will be local to the method.
Do I need a separate utility object that each request would instanciate
that could take a reference to the app scoped Function collection in
order to get this done in a thread safe manner?
I'm trying to avoid going to the DB and loading up the Functions and Sub
Functions and on down the chain (the Functions object actually has a
SubFunctions property that is another FunctionCollection) for everey
user/request.
Reply to this message...
Brian Espey
won't the FunctionCollection you create be allocated
as a local variable inside the function? if so, then
each request would see it's own FunctionCollection
because each Thread has its own stack (which is where
the local variable references are created). there
shouldn't be any concurrency issues, if I understand
you correctly.
Brian
--- Mark Feinholz <
Click here to reveal e-mail address
> wrote:
[Original message clipped]
__________________________________________________
Do You Yahoo!?
Sign up for SBC Yahoo! Dial - First Month Free
http://sbc.yahoo.com
Reply to this message...
Mark Feinholz
You do understand me correctly, thanks for taking the time to read my
post that carefully! Each thread has its own stack! That's good to know
because it also helps me understand how a static method that uses its
own local variables keeps other asp threads from running into eachother.
Thanks again. Mark.
-----Original Message-----
From: Brian Espey [mailto:
Click here to reveal e-mail address
]
Sent: Wednesday, July 10, 2002 5:29 PM
To: aspngarchitecture
Subject: [aspngarchitecture] Re: Multi-threading issues with Application
scoped objects
won't the FunctionCollection you create be allocated
as a local variable inside the function? if so, then
each request would see it's own FunctionCollection
because each Thread has its own stack (which is where
the local variable references are created). there
shouldn't be any concurrency issues, if I understand
you correctly.
Brian
--- Mark Feinholz <
Click here to reveal e-mail address
> wrote:
[Original message clipped]
__________________________________________________
Do You Yahoo!?
Sign up for SBC Yahoo! Dial - First Month Free
http://sbc.yahoo.com
| [aspngarchitecture] member
Click here to reveal e-mail address
= YOUR ID
|
http://www.asplists.com/asplists/aspngarchitecture.asp
= JOIN/QUIT
|
http://www.asplists.com/search
= SEARCH Archives
Reply to this message...
Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us
-
Terms of Use
-
Privacy Policy
-
www.dotnet247.com