473,466 Members | 1,320 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Cache per Thread

I have an ASP.Net Web Application where I depended on Sessions to share
information across the code. One of the buttons the user clicked, take
a long time to process. So, I started multi-threading the function
behind that button, but then I hit a brick wall - the new thread has no
access to Context.Current and therefore cannot see the Session
variables.

I understand why threads should not depend on Context.Current as they
can outlive the context's lifespan. I also understand that I can pass
the User Information that was stored in a Session as a parameter to my
thread. The problem is that I have 100's of functions I wrote that
depended on Session and now I have to go through all of them to
accomodate the thread limitation.

My question is: Is there a Cache I can depend on at the thread level to
store User Information that I can share and access from all of my
functions ?

BTW, I use classes within classes so I have several levels on hierarchy
and passing information down/up that tree is non-trivial. I am looking
for cache that I can access from anywhere on that thread.

I have a unique ID per thread. So, one thing I thought of doing is to
put a HashTable on the Application stack in Global.asax where the key
is that Unique ID. But then how do I propagate that Unique ID
throughout all the functions in that thread ? I still come to the same
problem - I need some cache space that can be accessed from any
function or class on that thread.

Please help as I have spun my wheels for days now.

Aladdin

Jan 6 '06 #1
2 1700
Aladdin,
At first blush it sounds like you might really be shooting yourself in the
foot here.
"Multithreading" Button clicks in a ASP.NET application, where the page
class itself has an extremely limited lifetime, is likely to be fraught with
all kinds of additional problems besides just the fact that the button click
"takes a long time to process".

You could use Remote Scripting (AJAX) to do the processing from the button -
click asynchronously, and if you use the right infrastructure ("Anthem.net"
or "MagicAjax") for example, you would still have access to the statefulness
of the page (including Session).

Hope it helps, just my 2 cents.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"anassar" wrote:
I have an ASP.Net Web Application where I depended on Sessions to share
information across the code. One of the buttons the user clicked, take
a long time to process. So, I started multi-threading the function
behind that button, but then I hit a brick wall - the new thread has no
access to Context.Current and therefore cannot see the Session
variables.

I understand why threads should not depend on Context.Current as they
can outlive the context's lifespan. I also understand that I can pass
the User Information that was stored in a Session as a parameter to my
thread. The problem is that I have 100's of functions I wrote that
depended on Session and now I have to go through all of them to
accomodate the thread limitation.

My question is: Is there a Cache I can depend on at the thread level to
store User Information that I can share and access from all of my
functions ?

BTW, I use classes within classes so I have several levels on hierarchy
and passing information down/up that tree is non-trivial. I am looking
for cache that I can access from anywhere on that thread.

I have a unique ID per thread. So, one thing I thought of doing is to
put a HashTable on the Application stack in Global.asax where the key
is that Unique ID. But then how do I propagate that Unique ID
throughout all the functions in that thread ? I still come to the same
problem - I need some cache space that can be accessed from any
function or class on that thread.

Please help as I have spun my wheels for days now.

Aladdin

Jan 6 '06 #2
Peter:

That is an excellent idea, I never thought of. I am a novice to Ajax.
Can you please give me a basic example that posts to an aspx page
asynchronously with query string parameters ?

On a seperate note, for my sanity, is there such a thing thread-wide
cache in ASP.Net or is cache only at the application level ? And what
is the best way to share data between different classes with several
levels down besides passing parameters ?

Thank you very much for your response,

Aladdin

Jan 7 '06 #3

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

Similar topics

0
by: Timo | last post by:
I'm trying to make a thread safe object cache without locking. The objects are cached by the id of the data dict given in __new__. Objects are removed from the cache as soon as they are no longer...
4
by: Mat | last post by:
Hi, I've stumbled onto a problem when using the caching object in ASP.Net. I'm placing a static dataset to the cache as the data only changes once a day. Whilst writing to the cache I'm using...
1
by: Christopher | last post by:
In one of our ASP.NET Pages, we are starting a new background thread that we do not need to go and get any status on or use after the page finishes. The thread merely does some background stuff on...
1
by: William Sullivan | last post by:
I'm trying to nail down some issues with the cache in my application. Currently, I have an object that stands between my business logic and database logic called CacheLogic (cute, no?). ...
6
by: Adam | last post by:
On an xp machine, the caching works as expected. I have deployed to a win2k server, and an item I add to the cache expires almost immediately some times and in under a minute in other times. The...
13
by: Andrew Morton | last post by:
I am caching some data in VB.NET using System.Web.Caching, is it possible to lock the cache so that other sessions attempting to access the same cache wait when it is being updated? I have the...
1
by: Macca | last post by:
Hi I have a N-tier ASP.NET application that uses a data access tier to get data from a database and pass it to the middleware/business tier for processing/filtering and then passes the modified...
5
by: Joseph Geretz | last post by:
Of course, I can store a C# class instance to the Server Cache (this.Context.Cache). I've tried it. My question is, will this destroy the scalability of my application? My background is VB6....
4
by: =?Utf-8?B?Y2F0?= | last post by:
As per Anthony's suggestion, I'm moving this discussion thread to this group. The history: We recently moved an older ASP.NET 1.1 code base on to ASP.NET 2.0, .NET 3.0 and Windows 2003 Server...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.