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

Using Cache expiration to invoke Delegates...

Hello

I'm trying to use Cache expiration and its callback feature to easily
add automated tasks programmatically. The task should be run when the
Cache object expired

The problem I'm facing is that some tasks will only be expiring (thus
running) in 2 months.
What if the server needs to reboot? Will the Cache be lost (and with
it all my Tasks) ?

If so, how could I save the Cache Objects of choice (my Tasks) exactly
as they are. These Tasks contain a Delegate holding the address of the
method to run, so I doubt I can serialize this to XML or to a DB...

All suggestions and advice are very welcome!
Beren.
Nov 19 '05 #1
4 1430
Why dont you store the tasks in an XML or other data storage and poll this
on a regular basis instead of trying to implement what seems to me ( and I
am probably quite wrong ) to be an overly complicated method of deciding
when to run a task ?

If you must serialize the Objects in cache, cant you add the <Serialize>
Attribute to them and then store them ?

All in all this sounds like a precarious way of designing a system. Having
said that I dont really know the ins and outs of why you have architected it
this way so I am really in no position to judge.

Regards Mr N

"Beren" <be***@angband.me> wrote in message
news:i2********************************@4ax.com...
Hello

I'm trying to use Cache expiration and its callback feature to easily
add automated tasks programmatically. The task should be run when the
Cache object expired

The problem I'm facing is that some tasks will only be expiring (thus
running) in 2 months.
What if the server needs to reboot? Will the Cache be lost (and with
it all my Tasks) ?

If so, how could I save the Cache Objects of choice (my Tasks) exactly
as they are. These Tasks contain a Delegate holding the address of the
method to run, so I doubt I can serialize this to XML or to a DB...

All suggestions and advice are very welcome!
Beren.

Nov 19 '05 #2
Hi Beren,

First, yes, your Cache isn't nearly as safe a container as you might think.
In fact, it will be dumped every time the Application shuts down, which will
happen any time there are no requests from anyone for 20 minutes. You can
extend the lifetime of the Application just like extending the lifetime of
the Session, but that only reduces the issue, and does not elimate it.

So, the first thing you need to do is determine how critical these tasks
are. What happens if they don't run? If they are indeed critical, you need a
different solution than Cache. Any solution that is reliable would involve
serializing data to the disk, whether this is via XML, binary files,
database, or possibly Windows Messaging services.

That also means that you're going to have to remodel your tasks not to use
delegates. If you use Windows Messaging services, or the soon-to-be-released
Indigo Services, you get both reliability of data, plus guaranteed delivery
of the message. It is important to note that delegates are not the only way
to determine what method is executed. Any message can include some sort of
information about what should be done in response to the message.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Big things are made up of
lots of little things.

"Beren" <be***@angband.me> wrote in message
news:i2********************************@4ax.com...
Hello

I'm trying to use Cache expiration and its callback feature to easily
add automated tasks programmatically. The task should be run when the
Cache object expired

The problem I'm facing is that some tasks will only be expiring (thus
running) in 2 months.
What if the server needs to reboot? Will the Cache be lost (and with
it all my Tasks) ?

If so, how could I save the Cache Objects of choice (my Tasks) exactly
as they are. These Tasks contain a Delegate holding the address of the
method to run, so I doubt I can serialize this to XML or to a DB...

All suggestions and advice are very welcome!
Beren.

Nov 19 '05 #3
Thank you for the replies,

I've been thinking this over and right now I'm planning to make this
work via Reflection. In my Task object I could store the Assembly,
ClassName and MethodName I want to invoke. This way no Delegates are
needed and I can serialize this information easily to XML.
Expiry check would have to happen with a Timer that regulary checks
this dataset, no Cache expiry dates anymore...

To stay somewhat faithful to the title of this post: Why not cache the
XML as a dependency... :)

Kevin, your informative post boiled another question up for me
concerning the Cache, but perhaps this belongs in the Caching group...

So I decide to cache the XML (dataset) with my reflection data for
faster access. When the Cache is dumped after 20 minutes as you say,
will the CacheCallback method still be called? That might prove to be
disastrous. And finally -to be all safe- I guess there's no other
option but to re-Cache the tasks dataset in Application_Start.
These tasks are one of the core parts from the system.
Thanks alot,

Beren.

On Sat, 1 Oct 2005 11:59:56 -0400, "Kevin Spencer"
<ke***@DIESPAMMERSDIEtakempis.com> wrote:
Hi Beren,

First, yes, your Cache isn't nearly as safe a container as you might think.
In fact, it will be dumped every time the Application shuts down, which will
happen any time there are no requests from anyone for 20 minutes. You can
extend the lifetime of the Application just like extending the lifetime of
the Session, but that only reduces the issue, and does not elimate it.

So, the first thing you need to do is determine how critical these tasks
are. What happens if they don't run? If they are indeed critical, you need a
different solution than Cache. Any solution that is reliable would involve
serializing data to the disk, whether this is via XML, binary files,
database, or possibly Windows Messaging services.

That also means that you're going to have to remodel your tasks not to use
delegates. If you use Windows Messaging services, or the soon-to-be-released
Indigo Services, you get both reliability of data, plus guaranteed delivery
of the message. It is important to note that delegates are not the only way
to determine what method is executed. Any message can include some sort of
information about what should be done in response to the message.

Nov 19 '05 #4
Community Server (http://www.communityserver.org) runs several tasks in
the background. Some of the tasks include sending emails, updating
statistics and others. This is an article describing how to use it.

http://www.kdkeys.com/blogs/kingsley...4/10/4525.aspx

Perhaps this can give you some ideas for your situation.

Nov 19 '05 #5

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

Similar topics

1
by: Joe Fallon | last post by:
I am trying to setup a cache that refreshes itself every hour. (My sample code is for every minute so I can test it.) I have found some examples that I thought worked but they all seem to fail....
4
by: NWx | last post by:
Hi, I' trying to implement a callback method when a cache object expires I want to do this to automatically logout user after a timeout (for demo purposes) My thought is, when user logon,...
1
by: Guadala Harry | last post by:
AFAIK, when placing an object into the Cache with no special instructions (no dependencies, sliding expirations, hard expirations, etc), it will just sit there in the Cache until the system decides...
3
by: MattC | last post by:
Hi, I am persisting the viewstate for each page into the Cache object, below is shown my methods for saving and loading: I am able to save the viewstate to the cache and most times I can load...
2
by: Kikoz | last post by:
Hi all. I keep my ViewState in server's cache. Works fine except when user leaves the page opened for a long time (2 hours or so). Then if he/she tries to post it back the server throws an...
15
by: Nathan | last post by:
I have an aspx page with a data grid, some textboxes, and an update button. This page also has one html input element with type=file (not inside the data grid and runat=server). The update...
2
by: =?Utf-8?B?Y2F0?= | last post by:
We recently moved an older ASP.NET 1.1 code base on to ASP.NET 2.0, .NET 3.0 and Windows 2003 Server SP2. We started experiencing the following issue with the web cache (the code is straightforward...
5
by: =?Utf-8?B?Y2hlY2tyYWlzZXJAY29tbXVuaXR5Lm5vc3BhbQ== | last post by:
I have a site which I secure with forms authentication. When the user's sign on and hit one of the secure pages, I have this line in my code to ensure that the browser does not cache the page;...
3
by: David K in San Jose | last post by:
I'm using managed (CLR) C++ in VS2005 to create a Windows app that contains a form named "MyForm". In the code for that form I'm trying to invoke some static functions by using an array of function...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
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:
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
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...

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.