473,387 Members | 3,033 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,387 software developers and data experts.

Timer question


I need some help on timers. My app is asp.net 1.1 website running in a
shared hosting environment with a third-party service provider. I currently
request and cache 20 - 40 remote RSS feeds. When a user requests the page,
the app first tries to retrieve a feed from cache, if the feed has expired,
it goes off and request the file from the web.

If create a CacheItemRemovedCallback for each item to automatically
re-request an expired cached page, will I clog up the ThreadPool?

Would I be better off using Threading.Timer or
ThreadPool.RegisterWaitForSingleObject?(although I far as I can tell both
methods create wait operations on threadpool threads)

Richard

Sep 19 '05 #1
5 2108
Hi Richard,

Welcome to MSDN newsgroup.
AS for the Timer question you mentionded, here are some of my understanding
and suggestions:

For the ASP.NET's Cache entry's RemoveCallback function, generally they're
called when the underlying background polling thread found an certain cache
item expired, and this background thread is not necessarily a thread pool
thread, of course we don't worry that removecallback function will consume
many thread pool thread. However, since the background polling thread(for
checking cache expireation) is important, we'd recommend that we don't put
two many tasks (long run ) in removecallback handler.

Also, I don't suggest that we use ThreadPool's RegisterWaitForSingleObject
or other methods to do the work since they'll occupy threadpool threads
which is important for serving asp.net requests. In fact, my suggestion
is just let the items expire and rerequest them on the next request from
page, and retrieve them from remote url and cache in the memory cache.
Just like:

//////////
If (Cache[key] == null)
{
//retrieve from remote place and insert into cache
}

return Cache[key];
/////////

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| From: "Richard P" <or**@community.nospam>
| Subject: Timer question
| Date: Mon, 19 Sep 2005 19:42:00 +0100
| Lines: 18
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
| X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
| X-RFC2646: Format=Flowed; Original
| Message-ID: <OC**************@TK2MSFTNGP15.phx.gbl>
| Newsgroups: microsoft.public.dotnet.general
| NNTP-Posting-Host: host86-129-136-61.range86-129.btcentralplus.com
86.129.136.61
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP15.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.dotnet.general:50240
| X-Tomcat-NG: microsoft.public.dotnet.general
|
|
| I need some help on timers. My app is asp.net 1.1 website running in a
| shared hosting environment with a third-party service provider. I
currently
| request and cache 20 - 40 remote RSS feeds. When a user requests the
page,
| the app first tries to retrieve a feed from cache, if the feed has
expired,
| it goes off and request the file from the web.
|
| If create a CacheItemRemovedCallback for each item to automatically
| re-request an expired cached page, will I clog up the ThreadPool?
|
| Would I be better off using Threading.Timer or
| ThreadPool.RegisterWaitForSingleObject?(although I far as I can tell both
| methods create wait operations on threadpool threads)
|
| Richard
|
|
|
|

Sep 20 '05 #2
Hi Steven,

Thanks for your reply. So from what you say CacheItemRemovedCallback is the
most efficient of the three timer options because wait operations create no
additional load. The CLR automatically polls the cache for expired items and
only starts a threadpool thread when its time to execute the callback.
Threading.Timer and RegisterWaitForSingleObject will each spawn an extra
thread on the thread pool to perform a wait operation and then spawn another
thread to run the callback.

The request triggered method you recommend is what I am currently doing. The
problem is that when throughput is low, the response times can be quite
slow - even though I fire the RSS requests in parallel.

It seems to me therefore that it is ok to create any number (within reason)
of short term or long term CacheItemRemovedCallbacks, because no additional
load is created for the wait operations. The key issue is to avoid
congesting the threadpool with loads of callback operations, particularly if
each operation is long-running and non-CPU intensive, such as when
requesting a remote RSS feed.

Please let me know if I've got this wrong.

thanks

Richard

"Steven Cheng[MSFT]" <st*****@online.microsoft.com> wrote in message
news:PT**************@TK2MSFTNGXA01.phx.gbl...
Hi Richard,

Welcome to MSDN newsgroup.
AS for the Timer question you mentionded, here are some of my
understanding
and suggestions:

For the ASP.NET's Cache entry's RemoveCallback function, generally they're
called when the underlying background polling thread found an certain
cache
item expired, and this background thread is not necessarily a thread pool
thread, of course we don't worry that removecallback function will consume
many thread pool thread. However, since the background polling thread(for
checking cache expireation) is important, we'd recommend that we don't put
two many tasks (long run ) in removecallback handler.

Also, I don't suggest that we use ThreadPool's RegisterWaitForSingleObject
or other methods to do the work since they'll occupy threadpool threads
which is important for serving asp.net requests. In fact, my suggestion
is just let the items expire and rerequest them on the next request from
page, and retrieve them from remote url and cache in the memory cache.
Just like:

//////////
If (Cache[key] == null)
{
//retrieve from remote place and insert into cache
}

return Cache[key];
/////////

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| From: "Richard P" <or**@community.nospam>
| Subject: Timer question
| Date: Mon, 19 Sep 2005 19:42:00 +0100
| Lines: 18
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
| X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
| X-RFC2646: Format=Flowed; Original
| Message-ID: <OC**************@TK2MSFTNGP15.phx.gbl>
| Newsgroups: microsoft.public.dotnet.general
| NNTP-Posting-Host: host86-129-136-61.range86-129.btcentralplus.com
86.129.136.61
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP15.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.dotnet.general:50240
| X-Tomcat-NG: microsoft.public.dotnet.general
|
|
| I need some help on timers. My app is asp.net 1.1 website running in a
| shared hosting environment with a third-party service provider. I
currently
| request and cache 20 - 40 remote RSS feeds. When a user requests the
page,
| the app first tries to retrieve a feed from cache, if the feed has
expired,
| it goes off and request the file from the web.
|
| If create a CacheItemRemovedCallback for each item to automatically
| re-request an expired cached page, will I clog up the ThreadPool?
|
| Would I be better off using Threading.Timer or
| ThreadPool.RegisterWaitForSingleObject?(although I far as I can tell
both
| methods create wait operations on threadpool threads)
|
| Richard
|
|
|
|

Sep 20 '05 #3
Hi Richard,

Thanks for your prompt response.
Yes, using RemoveCallBack is ok , however since you're put many longrun
operations in it, I'm not sure whether this has kill your app's throughput.
Also, it seems that the reason you use RemoveCallBack now is just need to
rerequest the in memory RSS(or can I use refresh? I think it's rather
exactly what you do, yes?)

If so, I think you can consider use a separate background thread to do the
work. when adding RSS content retrieved from remote url into application
Cache, you can event not specify a expiration timeout. And create a
background thread in Application_Start time which will refresh the cached
RSSs in the cache once every certain time period. To create such as
background thread, you can just using the System.Threading.Thread to
construct a thread and a global ThreadProc , after start, store the
thread's reference in the applicationStates or be held in a global
variable(static vartiable). Thus, all the RSS retrieving operations is
done in the background thread, totally nothing related to threadpool
thread.

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| From: "Richard P" <or**@community.nospam>
| References: <OC**************@TK2MSFTNGP15.phx.gbl>
<PT**************@TK2MSFTNGXA01.phx.gbl>
| Subject: Re: Timer question
| Date: Tue, 20 Sep 2005 07:53:24 +0100
| Lines: 115
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
| X-RFC2646: Format=Flowed; Original
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
| Message-ID: <#D**************@TK2MSFTNGP12.phx.gbl>
| Newsgroups: microsoft.public.dotnet.general
| NNTP-Posting-Host: host86-129-127-92.range86-129.btcentralplus.com
86.129.127.92
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP12.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.dotnet.general:50273
| X-Tomcat-NG: microsoft.public.dotnet.general
|
| Hi Steven,
|
| Thanks for your reply. So from what you say CacheItemRemovedCallback is
the
| most efficient of the three timer options because wait operations create
no
| additional load. The CLR automatically polls the cache for expired items
and
| only starts a threadpool thread when its time to execute the callback.
| Threading.Timer and RegisterWaitForSingleObject will each spawn an extra
| thread on the thread pool to perform a wait operation and then spawn
another
| thread to run the callback.
|
| The request triggered method you recommend is what I am currently doing.
The
| problem is that when throughput is low, the response times can be quite
| slow - even though I fire the RSS requests in parallel.
|
| It seems to me therefore that it is ok to create any number (within
reason)
| of short term or long term CacheItemRemovedCallbacks, because no
additional
| load is created for the wait operations. The key issue is to avoid
| congesting the threadpool with loads of callback operations, particularly
if
| each operation is long-running and non-CPU intensive, such as when
| requesting a remote RSS feed.
|
| Please let me know if I've got this wrong.
|
| thanks
|
| Richard
|
|
|
| "Steven Cheng[MSFT]" <st*****@online.microsoft.com> wrote in message
| news:PT**************@TK2MSFTNGXA01.phx.gbl...
| > Hi Richard,
| >
| > Welcome to MSDN newsgroup.
| > AS for the Timer question you mentionded, here are some of my
| > understanding
| > and suggestions:
| >
| > For the ASP.NET's Cache entry's RemoveCallback function, generally
they're
| > called when the underlying background polling thread found an certain
| > cache
| > item expired, and this background thread is not necessarily a thread
pool
| > thread, of course we don't worry that removecallback function will
consume
| > many thread pool thread. However, since the background polling
thread(for
| > checking cache expireation) is important, we'd recommend that we don't
put
| > two many tasks (long run ) in removecallback handler.
| >
| > Also, I don't suggest that we use ThreadPool's
RegisterWaitForSingleObject
| > or other methods to do the work since they'll occupy threadpool threads
| > which is important for serving asp.net requests. In fact, my
suggestion
| > is just let the items expire and rerequest them on the next request from
| > page, and retrieve them from remote url and cache in the memory cache.
| > Just like:
| >
| > //////////
| > If (Cache[key] == null)
| > {
| > //retrieve from remote place and insert into cache
| > }
| >
| > return Cache[key];
| > /////////
| >
| > Thanks,
| >
| > Steven Cheng
| > Microsoft Online Support
| >
| > Get Secure! www.microsoft.com/security
| > (This posting is provided "AS IS", with no warranties, and confers no
| > rights.)
| > --------------------
| > | From: "Richard P" <or**@community.nospam>
| > | Subject: Timer question
| > | Date: Mon, 19 Sep 2005 19:42:00 +0100
| > | Lines: 18
| > | X-Priority: 3
| > | X-MSMail-Priority: Normal
| > | X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
| > | X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
| > | X-RFC2646: Format=Flowed; Original
| > | Message-ID: <OC**************@TK2MSFTNGP15.phx.gbl>
| > | Newsgroups: microsoft.public.dotnet.general
| > | NNTP-Posting-Host: host86-129-136-61.range86-129.btcentralplus.com
| > 86.129.136.61
| > | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP15.phx.gbl
| > | Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.dotnet.general:50240
| > | X-Tomcat-NG: microsoft.public.dotnet.general
| > |
| > |
| > | I need some help on timers. My app is asp.net 1.1 website running in a
| > | shared hosting environment with a third-party service provider. I
| > currently
| > | request and cache 20 - 40 remote RSS feeds. When a user requests the
| > page,
| > | the app first tries to retrieve a feed from cache, if the feed has
| > expired,
| > | it goes off and request the file from the web.
| > |
| > | If create a CacheItemRemovedCallback for each item to automatically
| > | re-request an expired cached page, will I clog up the ThreadPool?
| > |
| > | Would I be better off using Threading.Timer or
| > | ThreadPool.RegisterWaitForSingleObject?(although I far as I can tell
| > both
| > | methods create wait operations on threadpool threads)
| > |
| > | Richard
| > |
| > |
| > |
| > |
| >
|
|
|

Sep 20 '05 #4
Steven

I'll give that a go. Thanks a lot

Richard
"Steven Cheng[MSFT]" <st*****@online.microsoft.com> wrote in message
news:u$**************@TK2MSFTNGXA01.phx.gbl...
Hi Richard,

Thanks for your prompt response.
Yes, using RemoveCallBack is ok , however since you're put many longrun
operations in it, I'm not sure whether this has kill your app's
throughput.
Also, it seems that the reason you use RemoveCallBack now is just need to
rerequest the in memory RSS(or can I use refresh? I think it's rather
exactly what you do, yes?)

If so, I think you can consider use a separate background thread to do the
work. when adding RSS content retrieved from remote url into application
Cache, you can event not specify a expiration timeout. And create a
background thread in Application_Start time which will refresh the cached
RSSs in the cache once every certain time period. To create such as
background thread, you can just using the System.Threading.Thread to
construct a thread and a global ThreadProc , after start, store the
thread's reference in the applicationStates or be held in a global
variable(static vartiable). Thus, all the RSS retrieving operations is
done in the background thread, totally nothing related to threadpool
thread.

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| From: "Richard P" <or**@community.nospam>
| References: <OC**************@TK2MSFTNGP15.phx.gbl>
<PT**************@TK2MSFTNGXA01.phx.gbl>
| Subject: Re: Timer question
| Date: Tue, 20 Sep 2005 07:53:24 +0100
| Lines: 115
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
| X-RFC2646: Format=Flowed; Original
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
| Message-ID: <#D**************@TK2MSFTNGP12.phx.gbl>
| Newsgroups: microsoft.public.dotnet.general
| NNTP-Posting-Host: host86-129-127-92.range86-129.btcentralplus.com
86.129.127.92
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP12.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.dotnet.general:50273
| X-Tomcat-NG: microsoft.public.dotnet.general
|
| Hi Steven,
|
| Thanks for your reply. So from what you say CacheItemRemovedCallback is
the
| most efficient of the three timer options because wait operations create
no
| additional load. The CLR automatically polls the cache for expired items
and
| only starts a threadpool thread when its time to execute the callback.
| Threading.Timer and RegisterWaitForSingleObject will each spawn an extra
| thread on the thread pool to perform a wait operation and then spawn
another
| thread to run the callback.
|
| The request triggered method you recommend is what I am currently doing.
The
| problem is that when throughput is low, the response times can be quite
| slow - even though I fire the RSS requests in parallel.
|
| It seems to me therefore that it is ok to create any number (within
reason)
| of short term or long term CacheItemRemovedCallbacks, because no
additional
| load is created for the wait operations. The key issue is to avoid
| congesting the threadpool with loads of callback operations,
particularly
if
| each operation is long-running and non-CPU intensive, such as when
| requesting a remote RSS feed.
|
| Please let me know if I've got this wrong.
|
| thanks
|
| Richard
|
|
|
| "Steven Cheng[MSFT]" <st*****@online.microsoft.com> wrote in message
| news:PT**************@TK2MSFTNGXA01.phx.gbl...
| > Hi Richard,
| >
| > Welcome to MSDN newsgroup.
| > AS for the Timer question you mentionded, here are some of my
| > understanding
| > and suggestions:
| >
| > For the ASP.NET's Cache entry's RemoveCallback function, generally
they're
| > called when the underlying background polling thread found an certain
| > cache
| > item expired, and this background thread is not necessarily a thread
pool
| > thread, of course we don't worry that removecallback function will
consume
| > many thread pool thread. However, since the background polling
thread(for
| > checking cache expireation) is important, we'd recommend that we don't
put
| > two many tasks (long run ) in removecallback handler.
| >
| > Also, I don't suggest that we use ThreadPool's
RegisterWaitForSingleObject
| > or other methods to do the work since they'll occupy threadpool
threads
| > which is important for serving asp.net requests. In fact, my
suggestion
| > is just let the items expire and rerequest them on the next request
from
| > page, and retrieve them from remote url and cache in the memory cache.
| > Just like:
| >
| > //////////
| > If (Cache[key] == null)
| > {
| > //retrieve from remote place and insert into cache
| > }
| >
| > return Cache[key];
| > /////////
| >
| > Thanks,
| >
| > Steven Cheng
| > Microsoft Online Support
| >
| > Get Secure! www.microsoft.com/security
| > (This posting is provided "AS IS", with no warranties, and confers no
| > rights.)
| > --------------------
| > | From: "Richard P" <or**@community.nospam>
| > | Subject: Timer question
| > | Date: Mon, 19 Sep 2005 19:42:00 +0100
| > | Lines: 18
| > | X-Priority: 3
| > | X-MSMail-Priority: Normal
| > | X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
| > | X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
| > | X-RFC2646: Format=Flowed; Original
| > | Message-ID: <OC**************@TK2MSFTNGP15.phx.gbl>
| > | Newsgroups: microsoft.public.dotnet.general
| > | NNTP-Posting-Host: host86-129-136-61.range86-129.btcentralplus.com
| > 86.129.136.61
| > | Path:
TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP15.phx.gbl
| > | Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.dotnet.general:50240
| > | X-Tomcat-NG: microsoft.public.dotnet.general
| > |
| > |
| > | I need some help on timers. My app is asp.net 1.1 website running in
a
| > | shared hosting environment with a third-party service provider. I
| > currently
| > | request and cache 20 - 40 remote RSS feeds. When a user requests the
| > page,
| > | the app first tries to retrieve a feed from cache, if the feed has
| > expired,
| > | it goes off and request the file from the web.
| > |
| > | If create a CacheItemRemovedCallback for each item to automatically
| > | re-request an expired cached page, will I clog up the ThreadPool?
| > |
| > | Would I be better off using Threading.Timer or
| > | ThreadPool.RegisterWaitForSingleObject?(although I far as I can tell
| > both
| > | methods create wait operations on threadpool threads)
| > |
| > | Richard
| > |
| > |
| > |
| > |
| >
|
|
|

Sep 21 '05 #5
You're welcome Richard,

Please feel free to post here if there're anything else we can help.

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| From: "Richard P" <or**@community.nospam>
| References: <OC**************@TK2MSFTNGP15.phx.gbl>
<PT**************@TK2MSFTNGXA01.phx.gbl>
<#D**************@TK2MSFTNGP12.phx.gbl>
<u$**************@TK2MSFTNGXA01.phx.gbl>
| Subject: Re: Timer question
| Date: Wed, 21 Sep 2005 11:32:10 +0100
| Lines: 200
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
| X-RFC2646: Format=Flowed; Original
| Message-ID: <u7**************@TK2MSFTNGP15.phx.gbl>
| Newsgroups: microsoft.public.dotnet.general
| NNTP-Posting-Host: host86-129-143-74.range86-129.btcentralplus.com
86.129.143.74
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP15.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.dotnet.general:50364
| X-Tomcat-NG: microsoft.public.dotnet.general
|
| Steven
|
| I'll give that a go. Thanks a lot
|
| Richard
|
|
| "Steven Cheng[MSFT]" <st*****@online.microsoft.com> wrote in message
| news:u$**************@TK2MSFTNGXA01.phx.gbl...
| > Hi Richard,
| >
| > Thanks for your prompt response.
| > Yes, using RemoveCallBack is ok , however since you're put many longrun
| > operations in it, I'm not sure whether this has kill your app's
| > throughput.
| > Also, it seems that the reason you use RemoveCallBack now is just need
to
| > rerequest the in memory RSS(or can I use refresh? I think it's rather
| > exactly what you do, yes?)
| >
| > If so, I think you can consider use a separate background thread to do
the
| > work. when adding RSS content retrieved from remote url into application
| > Cache, you can event not specify a expiration timeout. And create a
| > background thread in Application_Start time which will refresh the
cached
| > RSSs in the cache once every certain time period. To create such as
| > background thread, you can just using the System.Threading.Thread to
| > construct a thread and a global ThreadProc , after start, store the
| > thread's reference in the applicationStates or be held in a global
| > variable(static vartiable). Thus, all the RSS retrieving operations is
| > done in the background thread, totally nothing related to threadpool
| > thread.
| >
| > Thanks,
| >
| > Steven Cheng
| > Microsoft Online Support
| >
| > Get Secure! www.microsoft.com/security
| > (This posting is provided "AS IS", with no warranties, and confers no
| > rights.)
| >
| >
| > --------------------
| > | From: "Richard P" <or**@community.nospam>
| > | References: <OC**************@TK2MSFTNGP15.phx.gbl>
| > <PT**************@TK2MSFTNGXA01.phx.gbl>
| > | Subject: Re: Timer question
| > | Date: Tue, 20 Sep 2005 07:53:24 +0100
| > | Lines: 115
| > | X-Priority: 3
| > | X-MSMail-Priority: Normal
| > | X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
| > | X-RFC2646: Format=Flowed; Original
| > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
| > | Message-ID: <#D**************@TK2MSFTNGP12.phx.gbl>
| > | Newsgroups: microsoft.public.dotnet.general
| > | NNTP-Posting-Host: host86-129-127-92.range86-129.btcentralplus.com
| > 86.129.127.92
| > | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP12.phx.gbl
| > | Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.dotnet.general:50273
| > | X-Tomcat-NG: microsoft.public.dotnet.general
| > |
| > | Hi Steven,
| > |
| > | Thanks for your reply. So from what you say CacheItemRemovedCallback
is
| > the
| > | most efficient of the three timer options because wait operations
create
| > no
| > | additional load. The CLR automatically polls the cache for expired
items
| > and
| > | only starts a threadpool thread when its time to execute the callback.
| > | Threading.Timer and RegisterWaitForSingleObject will each spawn an
extra
| > | thread on the thread pool to perform a wait operation and then spawn
| > another
| > | thread to run the callback.
| > |
| > | The request triggered method you recommend is what I am currently
doing.
| > The
| > | problem is that when throughput is low, the response times can be
quite
| > | slow - even though I fire the RSS requests in parallel.
| > |
| > | It seems to me therefore that it is ok to create any number (within
| > reason)
| > | of short term or long term CacheItemRemovedCallbacks, because no
| > additional
| > | load is created for the wait operations. The key issue is to avoid
| > | congesting the threadpool with loads of callback operations,
| > particularly
| > if
| > | each operation is long-running and non-CPU intensive, such as when
| > | requesting a remote RSS feed.
| > |
| > | Please let me know if I've got this wrong.
| > |
| > | thanks
| > |
| > | Richard
| > |
| > |
| > |
| > | "Steven Cheng[MSFT]" <st*****@online.microsoft.com> wrote in message
| > | news:PT**************@TK2MSFTNGXA01.phx.gbl...
| > | > Hi Richard,
| > | >
| > | > Welcome to MSDN newsgroup.
| > | > AS for the Timer question you mentionded, here are some of my
| > | > understanding
| > | > and suggestions:
| > | >
| > | > For the ASP.NET's Cache entry's RemoveCallback function, generally
| > they're
| > | > called when the underlying background polling thread found an
certain
| > | > cache
| > | > item expired, and this background thread is not necessarily a thread
| > pool
| > | > thread, of course we don't worry that removecallback function will
| > consume
| > | > many thread pool thread. However, since the background polling
| > thread(for
| > | > checking cache expireation) is important, we'd recommend that we
don't
| > put
| > | > two many tasks (long run ) in removecallback handler.
| > | >
| > | > Also, I don't suggest that we use ThreadPool's
| > RegisterWaitForSingleObject
| > | > or other methods to do the work since they'll occupy threadpool
| > threads
| > | > which is important for serving asp.net requests. In fact, my
| > suggestion
| > | > is just let the items expire and rerequest them on the next request
| > from
| > | > page, and retrieve them from remote url and cache in the memory
cache.
| > | > Just like:
| > | >
| > | > //////////
| > | > If (Cache[key] == null)
| > | > {
| > | > //retrieve from remote place and insert into cache
| > | > }
| > | >
| > | > return Cache[key];
| > | > /////////
| > | >
| > | > Thanks,
| > | >
| > | > Steven Cheng
| > | > Microsoft Online Support
| > | >
| > | > Get Secure! www.microsoft.com/security
| > | > (This posting is provided "AS IS", with no warranties, and confers
no
| > | > rights.)
| > | > --------------------
| > | > | From: "Richard P" <or**@community.nospam>
| > | > | Subject: Timer question
| > | > | Date: Mon, 19 Sep 2005 19:42:00 +0100
| > | > | Lines: 18
| > | > | X-Priority: 3
| > | > | X-MSMail-Priority: Normal
| > | > | X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
| > | > | X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
| > | > | X-RFC2646: Format=Flowed; Original
| > | > | Message-ID: <OC**************@TK2MSFTNGP15.phx.gbl>
| > | > | Newsgroups: microsoft.public.dotnet.general
| > | > | NNTP-Posting-Host: host86-129-136-61.range86-129.btcentralplus.com
| > | > 86.129.136.61
| > | > | Path:
| > TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP15.phx.gbl
| > | > | Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.dotnet.general:50240
| > | > | X-Tomcat-NG: microsoft.public.dotnet.general
| > | > |
| > | > |
| > | > | I need some help on timers. My app is asp.net 1.1 website running
in
| > a
| > | > | shared hosting environment with a third-party service provider. I
| > | > currently
| > | > | request and cache 20 - 40 remote RSS feeds. When a user requests
the
| > | > page,
| > | > | the app first tries to retrieve a feed from cache, if the feed
has
| > | > expired,
| > | > | it goes off and request the file from the web.
| > | > |
| > | > | If create a CacheItemRemovedCallback for each item to
automatically
| > | > | re-request an expired cached page, will I clog up the ThreadPool?
| > | > |
| > | > | Would I be better off using Threading.Timer or
| > | > | ThreadPool.RegisterWaitForSingleObject?(although I far as I can
tell
| > | > both
| > | > | methods create wait operations on threadpool threads)
| > | > |
| > | > | Richard
| > | > |
| > | > |
| > | > |
| > | > |
| > | >
| > |
| > |
| > |
| >
|
|
|

Sep 22 '05 #6

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

Similar topics

3
by: brian | last post by:
I have an ASP.Net application that uses impersonation. This works fine for accessing/executing the application. However, the app utilizes a timer, that when fired uses the <machine>ASPNET...
6
by: Steve Jorgensen | last post by:
I know quite well that this question falls into the category of "why does Access misbehave when I do unexpected things to its objects?", but I thought I'd ask anyway, and see if anyone knows. ...
1
by: Paul Tomlinson | last post by:
Question about a System.Threading.Timer object and the "state" object you pass to it... Timer stateTimer = new Timer( = new TimerCallback( OnTimer ), o, 1000, 1000); I have an array of timer...
4
by: Richard P | last post by:
I need some help on timers. My app is asp.net 1.1 website running in a shared hosting environment with a third-party service provider. I currently request and cache 20 - 40 remote RSS feeds. When a...
7
by: RobKinney1 | last post by:
Hello, Wow...I have one for you all and hopefully I am not understanding this timer object correctly. I have a timer setup that pulses a connection through a socket every 60 seconds. But it...
12
by: Gina_Marano | last post by:
I have created an array of timers (1-n). At first I just created windows form timers but I read that system timers are better for background work. The timers will just be monitoring different...
11
by: Hotrod2000 | last post by:
I'm quite new to programming but I'm having problems getting a timer to work in visual studio.net I've created a timer on a form, enabled it and then typed the following code (from the mdsn...
16
by: Peter Oliphant | last post by:
Note that although this involves SAPI, it is more a question about Timers and event handlers. I wrote a Speech Recognize handler (SAPI), and put some code in it to enable a Timer. It would not...
11
by: Anil Gupte/iCinema.com | last post by:
When I use this Dim instance As New Timer I get the error: Error 1 Overload resolution failed because no accessible 'New' accepts this number of arguments. Yet, in the help section for...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: 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
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.