473,408 Members | 1,702 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,408 software developers and data experts.

Are timers safe for asp.net apps?


Hello,

I need a timer functionality in my asp.net app. I have dropped the
timer component available on the toolbox of the IDE on global.asax.cx
designer page view and dubble clicked to include the code and event for it .

My first attempt to run the code resulted in aspnet_wp.exe hanging with a
huge amount of memory.

How do i best accomplish this(use the timer)?
many thanks

JB
Nov 19 '05 #1
21 1403
What do you want to do ?

Do you need a timer server side or client side ?

Patrice

--

"jensen bredal" <je***********@yahoo.dk> a écrit dans le message de
news:eY****************@TK2MSFTNGP15.phx.gbl...

Hello,

I need a timer functionality in my asp.net app. I have dropped the
timer component available on the toolbox of the IDE on global.asax.cx
designer page view and dubble clicked to include the code and event for it ..
My first attempt to run the code resulted in aspnet_wp.exe hanging with a
huge amount of memory.

How do i best accomplish this(use the timer)?
many thanks

JB

Nov 19 '05 #2
It sounds like you are using a System.Timers Timer, which is ok to use
server side, although there are some gotchas.

What does yoru code do? The timer itself should not cause hangs and
memory problems.

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Tue, 3 May 2005 16:25:50 +0200, "jensen bredal"
<je***********@yahoo.dk> wrote:

Hello,

I need a timer functionality in my asp.net app. I have dropped the
timer component available on the toolbox of the IDE on global.asax.cx
designer page view and dubble clicked to include the code and event for it .

My first attempt to run the code resulted in aspnet_wp.exe hanging with a
huge amount of memory.

How do i best accomplish this(use the timer)?
many thanks

JB


Nov 19 '05 #3
need server side timer.

Nov 19 '05 #4
I need to update my application data in cache.

Will this actually be multithreaded or will it cause requests to wait for my
update?
Nov 19 '05 #5
You better tell us what are you going to achieve. You might be on a wrong
track altogether.

Eliyahu

"jensen bredal" <je***********@yahoo.dk> wrote in message
news:Ov**************@tk2msftngp13.phx.gbl...
need server side timer.

Nov 19 '05 #6
I saw in the other thread that is to update a cache ? What are you using to
handle this cache ?

The "cache" class already has an expiration mecanism. You'll have just to
reload the data if they are missing (you can even have a callback the entry
is cleaned up)... IMO you don't need a timer for this...

Other than that it's likely you have something that is not cleaned up
properly...

Patrice
--

"jensen bredal" <je***********@yahoo.dk> a écrit dans le message de
news:Ov**************@tk2msftngp13.phx.gbl...
need server side timer.

Nov 19 '05 #7
Well i need to update a cahce.
Right. So i could define a callback function that is called. I was not aware
that the cache had this capability.
Thanks
Nov 19 '05 #8
Thats a good suggestion Patrice. There is a callback event you can
hook when the cache item expires, and during the event processing
Jensen could update the cache entry.

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Tue, 3 May 2005 17:07:47 +0200, "Patrice" <no****@nowhere.com>
wrote:
I saw in the other thread that is to update a cache ? What are you using to
handle this cache ?

The "cache" class already has an expiration mecanism. You'll have just to
reload the data if they are missing (you can even have a callback the entry
is cleaned up)... IMO you don't need a timer for this...

Other than that it's likely you have something that is not cleaned up
properly...

Patrice


Nov 19 '05 #9
Youll find the doc for the Cache class around :
http://msdn.microsoft.com/library/de...ssAddTopic.asp

Patrice

--

"jensen bredal" <je***********@yahoo.dk> a écrit dans le message de
news:%2****************@TK2MSFTNGP15.phx.gbl...
Well i need to update a cahce.
Right. So i could define a callback function that is called. I was not aware that the cache had this capability.
Thanks

Nov 19 '05 #10
> I need to update my application data in cache.

Why do this in a timer? Why don't you let the Cache do its own timeout (you
can set the interval when calling Insert) and then just lazy load the data
the next time you need it? It's much simpler than doing a timer yourself.

-Brock
DevelopMentor
http://staff.develop.com/ballen


Nov 19 '05 #11
> Thats a good suggestion Patrice. There is a callback event you can
hook when the cache item expires, and during the event processing
Jensen could update the cache entry.


But again, why do it this way? It's usually much easier to just lazy load
the data upon the next request for it if the Cache has timed out. *shrug*

-Brock
DevelopMentor
http://staff.develop.com/ballen

Nov 19 '05 #12
Yes I mentioned the callback stuff but actually my personal preference would
be to lazy load the data...

The only thing I could think of would be those that are annoyed because they
are loading a fair amout of data taking then a hit. Generally they don't
want to delay the load so that the one who needs first the data doesn't
incur this hit (but IMO it has its own drawback such as what you do if there
is no data yet, even though I would likely try to see if all those data
wouldn't belong actually to distinct smaller caches)...

Patrice

--

"Brock Allen" <ba****@NOSPAMdevelop.com> a écrit dans le message de
news:62**********************@msnews.microsoft.com ...
Thats a good suggestion Patrice. There is a callback event you can
hook when the cache item expires, and during the event processing
Jensen could update the cache entry.


But again, why do it this way? It's usually much easier to just lazy load
the data upon the next request for it if the Cache has timed out. *shrug*

-Brock
DevelopMentor
http://staff.develop.com/ballen

Nov 19 '05 #13
Good point, Brock.

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Tue, 03 May 2005 08:31:15 -0700, Brock Allen
<ba****@NOSPAMdevelop.com> wrote:
Thats a good suggestion Patrice. There is a callback event you can
hook when the cache item expires, and during the event processing
Jensen could update the cache entry.


But again, why do it this way? It's usually much easier to just lazy load
the data upon the next request for it if the Cache has timed out. *shrug*

-Brock
DevelopMentor
http://staff.develop.com/ballen


Nov 19 '05 #14
How does lazy load work?
Nov 19 '05 #15
i use SqlHelper.cs
(http://msdn.microsoft.com/library/en...ml/daab-rm.asp)

I use the ExecuteDataSet method and the extract my table by using
ds.Table[0].

How can i use the so called "lazy load" with this method?

What should my cache dependancy be?
Nov 19 '05 #16
It just means that you load the data when they are first needed :

- check the cache
- if not in cache load and cache your data
- use them

Of course you could wrap this inside a method so that your app just call the
same method whithout having to deal with these low level details each
time...

Patrice

--

"jensen bredal" <je***********@yahoo.dk> a écrit dans le message de
news:Op**************@TK2MSFTNGP09.phx.gbl...
How does lazy load work?

Nov 19 '05 #17
DataSet ds = Cache["MyDataSet"] as DataSet;
if (ds == null)
{
ds = new DataSet();
/// Load ds from DB
Cache.Insert("MyDataSet", ds, .... );
}

In essence, look to see if it's in the cache, if it's not then get the data
and refresh the cache. This snippet is a bit oversimplified, as there's a
subtle timing issue here, but for the most part it'll work for you.

-Brock
DevelopMentor
http://staff.develop.com/ballen
How does lazy load work?


Nov 19 '05 #18
The delegate way sounds more interesting to me though. There there more
chance that my
the data get relaoded when there no request .

I'm right?


Nov 19 '05 #19
well that is thev problem.

Load DB in my case can take quiet some time , resulting in bad user
experience.
Nov 19 '05 #20
Yes it will. But what if no one requests that data in the meantime? You've
wasted effort for something that's not needed. That's why I suggested the
lazy load approach. You still have timing issues, too. Say the cache times
out, the item is removed and then your callback happens, but it hasn't yet
recreated the item in the cache... And then a page comes along and tries
to read the cache. You still have to wite the code in the page to check for
null and go back to the DB to reload it.

-Brock
DevelopMentor
http://staff.develop.com/ballen
The delegate way sounds more interesting to me though. There there
more
chance that my
the data get relaoded when there no request .
I'm right?


Nov 19 '05 #21

"Brock Allen" <ba****@NOSPAMdevelop.com> wrote in message
news:62**********************@msnews.microsoft.com ...
Yes it will. But what if no one requests that data in the meantime? You've
wasted effort for something that's not needed. That's why I suggested the
lazy load approach. You still have timing issues, too. Say the cache times
out, the item is removed and then your callback happens, but it hasn't yet
recreated the item in the cache... And then a page comes along and tries
to read the cache. You still have to wite the code in the page to check
for null and go back to the DB to reload it.


Well the second reason has convinced me that "Lazy load" has to be the way
to go.

Many Thanks

JB
Nov 19 '05 #22

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

Similar topics

0
by: Dmitry Demchuk | last post by:
Hi everybody. Recently I ran into situation with System.Threading.Timer in my ASP.NET application. I reinstalled Windows on one of my servers and got timers stop firing events after while, they...
1
by: Jason | last post by:
Hi all just a quick question. I have a windows service with a "Catalogue" class. I would like to know: if i put two "ServiceTimer" objects in my service 1. Do they run in separate threads...
6
by: dw | last post by:
I was listening to a Microsoft Webcast last Friday on Whidbey and migrating from 1.1 to 2.0. It mentioned having to use a converter tool to migrate apps to Whidbey. Is it safe to develop ASP.NET...
5
by: Michael C# | last post by:
Hi all, I set up a System.Timers.Time in my app. The code basically just updates the screen, but since the processing performed is so CPU-intensive, I wanted to make sure it gets updated...
4
by: Dave | last post by:
MS Virtual Server 2005 (not R2) with .Net 2003 I created a Console App and A windows form both with Timers in it. For the console i used system.timers and the windows form i used...
7
by: FredC | last post by:
I need some insight into timers, the static modifier and instance memory safety. public class myClass { protected static int i = 0; portected float myfloat; protected static Timer staticTimer =...
10
by: archana | last post by:
Hi all, can anyone tell me how server based timer in .net works? Which one of either system.timers.timer, system.threading.timer is better for use in windows service. How worker thread call...
5
by: Tony Gravagno | last post by:
I have a class that instantiates two Timer objects that fire at different intervals. My class can be instantiated within a Windows Form or from a Windows Service. Actions performed by one of the...
0
by: vpn | last post by:
I am trying to schedule a time to start the initial elapseEvent, but System.Timers.Timer does not seem to support this feature. The only Timer that support this is System.Threading.Timer which is...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.