473,609 Members | 2,134 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 CacheItemRemove dCallback 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.Regi sterWaitForSing leObject?(altho ugh I far as I can tell both
methods create wait operations on threadpool threads)

Richard

Sep 19 '05 #1
5 2129
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 RegisterWaitFor SingleObject
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.publi c.dotnet.genera l
| NNTP-Posting-Host: host86-129-136-61.range86-129.btcentralpl us.com
86.129.136.61
| Path: TK2MSFTNGXA01.p hx.gbl!TK2MSFTN GP08.phx.gbl!TK 2MSFTNGP15.phx. gbl
| Xref: TK2MSFTNGXA01.p hx.gbl microsoft.publi c.dotnet.genera l:50240
| X-Tomcat-NG: microsoft.publi c.dotnet.genera l
|
|
| 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 CacheItemRemove dCallback 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.Regi sterWaitForSing leObject?(altho ugh 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 CacheItemRemove dCallback 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 RegisterWaitFor SingleObject 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 CacheItemRemove dCallbacks, 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******** ******@TK2MSFTN GXA01.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 RegisterWaitFor SingleObject
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.publi c.dotnet.genera l
| NNTP-Posting-Host: host86-129-136-61.range86-129.btcentralpl us.com
86.129.136.61
| Path: TK2MSFTNGXA01.p hx.gbl!TK2MSFTN GP08.phx.gbl!TK 2MSFTNGP15.phx. gbl
| Xref: TK2MSFTNGXA01.p hx.gbl microsoft.publi c.dotnet.genera l:50240
| X-Tomcat-NG: microsoft.publi c.dotnet.genera l
|
|
| 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 CacheItemRemove dCallback 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.Regi sterWaitForSing leObject?(altho ugh 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_Sta rt 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.Threadin g.Thread to
construct a thread and a global ThreadProc , after start, store the
thread's reference in the applicationStat es 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************ **@TK2MSFTNGXA0 1.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.publi c.dotnet.genera l
| NNTP-Posting-Host: host86-129-127-92.range86-129.btcentralpl us.com
86.129.127.92
| Path: TK2MSFTNGXA01.p hx.gbl!TK2MSFTN GP08.phx.gbl!TK 2MSFTNGP12.phx. gbl
| Xref: TK2MSFTNGXA01.p hx.gbl microsoft.publi c.dotnet.genera l:50273
| X-Tomcat-NG: microsoft.publi c.dotnet.genera l
|
| Hi Steven,
|
| Thanks for your reply. So from what you say CacheItemRemove dCallback 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 RegisterWaitFor SingleObject 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 CacheItemRemove dCallbacks, 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******** ******@TK2MSFTN GXA01.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
RegisterWaitFor SingleObject
| > 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.publi c.dotnet.genera l
| > | NNTP-Posting-Host: host86-129-136-61.range86-129.btcentralpl us.com
| > 86.129.136.61
| > | Path: TK2MSFTNGXA01.p hx.gbl!TK2MSFTN GP08.phx.gbl!TK 2MSFTNGP15.phx. gbl
| > | Xref: TK2MSFTNGXA01.p hx.gbl microsoft.publi c.dotnet.genera l:50240
| > | X-Tomcat-NG: microsoft.publi c.dotnet.genera l
| > |
| > |
| > | 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 CacheItemRemove dCallback 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.Regi sterWaitForSing leObject?(altho ugh 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$******** ******@TK2MSFTN GXA01.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_Sta rt 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.Threadin g.Thread to
construct a thread and a global ThreadProc , after start, store the
thread's reference in the applicationStat es 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************ **@TK2MSFTNGXA0 1.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.publi c.dotnet.genera l
| NNTP-Posting-Host: host86-129-127-92.range86-129.btcentralpl us.com
86.129.127.92
| Path: TK2MSFTNGXA01.p hx.gbl!TK2MSFTN GP08.phx.gbl!TK 2MSFTNGP12.phx. gbl
| Xref: TK2MSFTNGXA01.p hx.gbl microsoft.publi c.dotnet.genera l:50273
| X-Tomcat-NG: microsoft.publi c.dotnet.genera l
|
| Hi Steven,
|
| Thanks for your reply. So from what you say CacheItemRemove dCallback 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 RegisterWaitFor SingleObject 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 CacheItemRemove dCallbacks, 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******** ******@TK2MSFTN GXA01.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
RegisterWaitFor SingleObject
| > 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.publi c.dotnet.genera l
| > | NNTP-Posting-Host: host86-129-136-61.range86-129.btcentralpl us.com
| > 86.129.136.61
| > | Path:
TK2MSFTNGXA01.p hx.gbl!TK2MSFTN GP08.phx.gbl!TK 2MSFTNGP15.phx. gbl
| > | Xref: TK2MSFTNGXA01.p hx.gbl microsoft.publi c.dotnet.genera l:50240
| > | X-Tomcat-NG: microsoft.publi c.dotnet.genera l
| > |
| > |
| > | 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 CacheItemRemove dCallback 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.Regi sterWaitForSing leObject?(altho ugh 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************ **@TK2MSFTNGXA0 1.phx.gbl>
<#D************ **@TK2MSFTNGP12 .phx.gbl>
<u$************ **@TK2MSFTNGXA0 1.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.publi c.dotnet.genera l
| NNTP-Posting-Host: host86-129-143-74.range86-129.btcentralpl us.com
86.129.143.74
| Path: TK2MSFTNGXA01.p hx.gbl!TK2MSFTN GP08.phx.gbl!TK 2MSFTNGP15.phx. gbl
| Xref: TK2MSFTNGXA01.p hx.gbl microsoft.publi c.dotnet.genera l:50364
| X-Tomcat-NG: microsoft.publi c.dotnet.genera l
|
| Steven
|
| I'll give that a go. Thanks a lot
|
| Richard
|
|
| "Steven Cheng[MSFT]" <st*****@online .microsoft.com> wrote in message
| news:u$******** ******@TK2MSFTN GXA01.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_Sta rt 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.Threadin g.Thread to
| > construct a thread and a global ThreadProc , after start, store the
| > thread's reference in the applicationStat es 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************ **@TK2MSFTNGXA0 1.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.publi c.dotnet.genera l
| > | NNTP-Posting-Host: host86-129-127-92.range86-129.btcentralpl us.com
| > 86.129.127.92
| > | Path: TK2MSFTNGXA01.p hx.gbl!TK2MSFTN GP08.phx.gbl!TK 2MSFTNGP12.phx. gbl
| > | Xref: TK2MSFTNGXA01.p hx.gbl microsoft.publi c.dotnet.genera l:50273
| > | X-Tomcat-NG: microsoft.publi c.dotnet.genera l
| > |
| > | Hi Steven,
| > |
| > | Thanks for your reply. So from what you say CacheItemRemove dCallback
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 RegisterWaitFor SingleObject 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 CacheItemRemove dCallbacks, 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******** ******@TK2MSFTN GXA01.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
| > RegisterWaitFor SingleObject
| > | > 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.publi c.dotnet.genera l
| > | > | NNTP-Posting-Host: host86-129-136-61.range86-129.btcentralpl us.com
| > | > 86.129.136.61
| > | > | Path:
| > TK2MSFTNGXA01.p hx.gbl!TK2MSFTN GP08.phx.gbl!TK 2MSFTNGP15.phx. gbl
| > | > | Xref: TK2MSFTNGXA01.p hx.gbl microsoft.publi c.dotnet.genera l:50240
| > | > | X-Tomcat-NG: microsoft.publi c.dotnet.genera l
| > | > |
| > | > |
| > | > | 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 CacheItemRemove dCallback 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.Regi sterWaitForSing leObject?(altho ugh 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
3635
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 identity. In order to correct this problem I've modified the Machine.config file in the \Microsoft.Net\Framework\v1.1.4322 folder. However, this didn't solve the problem; instead of using the user id and password specified in Machine.Config, the...
6
2897
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. When I make calls to SetWindowLong and SetLayeredWindowAttributes using the window handle for a poup form in Access, and call from within a timer event handler, it works most of the time, but sometimes will stop the timer from firing until I click...
1
3289
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 objects which all fire into my OnTimer( object state ) function very nicely. I pass in an object "o" on creation of this timer which I subsequently get passed to me in my OnTimer function. Now in the OnTimer function I want to modify the object...
4
297
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 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...
7
5991
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 seems recently connections just drop off because the timer stops firing. My question is if there is a timeout in the timer event that just shuts down the call if the timer event is taking too long to complete...?
12
5519
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 directories and updating a database. No interaction with the GUI. Problem is that the system timers do not have a tag property so I can tie in an object. example (old way):
11
2588
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 library as I thought this would be a good start!!!) but nothing happens :- Imports System.Timers
16
3243
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 do it. If I bring this same code outside this event handler, it works just fine. Is this normal?
11
4226
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 Timer (in VB 2005) this is exactly the syntax shown. I also tried:
0
8567
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8215
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8398
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6993
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6053
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5509
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4015
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2529
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 we have to send another system
1
1658
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.