私は IHttpHandler を持っていますが、これはセットアップに費用がかかり、スレッドセーフであるため、再利用の恩恵を受けることができると信じています。ただし、リクエストごとに新しいハンドラーが作成されています。ハンドラーが再利用されていません。
以下は、高価なセットアップなしの私の簡単なテストケースです。この単純なケースは私の問題を示しています:
public class MyRequestHandler : IHttpHandler
{
int nRequestsProcessed = 0;
public bool IsReusable
{
get { return true; }
}
public void ProcessRequest(HttpContext context)
{
nRequestsProcessed += 1;
Debug.WriteLine("Requests processed by this handler: " + nRequestsProcessed);
context.Response.ContentType = "text/plain";
context.Response.Write("Hello World");
}
}
Requests processed by this handler: 1
Requests processed by this handler: 1
Requests processed by this handler: 1
Requests processed by this handler: 1... at least 100 times. I never see > 1.
IsReusable の仕組みを誤解していますか? 再利用を打ち負かすことができるものは他にありますか? 私のハンドラは Silverlight アプリケーションから呼び出されています。