2009年11月29日日曜日

Timerでいいんすか

ちょっと試しにCacheDependencyを書いてたんだけど。

using System;
using System.Web.Caching;
using System.Timers;

namespace Sample
{ public class TimerCacheDependency:CacheDependency { private readonly Timer _timer; public TimerCacheDependency(DateTime expireTime) { _timer = new Timer((expireTime - DateTime.Now).TotalMilliseconds); _timer.Elapsed += (sender, e) => NotifyDependencyChanged(this, EventArgs.Empty); _timer.Start(); } protected override void DependencyDispose() { if (_timer == null) return; _timer.Dispose(); } } }

絶対時間でExpireさせるCacheDependency。 Timer使っていいのかな。なんかキャッシュに同時に1万とかデータ入れると1万のTimerだよね...。

Comparing the Timer Classes in the .NET Framework Class Library

特になにかリソースを消費しまくるってわけではない?

Pro ASP.NET 3.5 in C# 2008 - Google ブックス

こっちはSystem.Threading.Timer使ってるな...。ぶふ~。

2026年04月15日の記事一覧

(全 14 件) GoPro Mission 1 Proシリーズ | シネマクオリティのカメラが登場 グーグル、「Chrome」ブラウザーに「Skills」機能を追加--プロンプトを簡単活用 GoPro Announces New MISSION 1 Line of Pr...