如何在httpmodule中实现多线程/并发

时间:2013-10-30 11:48:11

标签: c# multithreading concurrency httpmodule httpapplication

这是我的源代码,我遇到困难,如果多个用户同时尝试访问文件,它阻止其他用户的请求直到完成第一个请求,我怎么能在这里编写并发代码,以便它允许所有用户同时访问文件。

    void IHttpModule.Init(HttpApplication httpApp)
    {
        this.HttpApplication = httpApp;
        httpApp.AuthenticateRequest += new EventHandler(context_AuthenticateRequest);
        httpApp.EndRequest += new EventHandler(context_EndRequest);
        httpApp.BeginRequest += new EventHandler(context_BeginRequest);
    }

    void context_BeginRequest(object sender, EventArgs e)
    {
        HttpApplication _httpApp = (HttpApplication)sender;

        this.IsWebDAVRequest = false;
        this.RequestHttpMethod = _httpApp.Context.Request.HttpMethod;

        foreach (string _enumName in Enum.GetNames(typeof(DavOptionsBase.HttpMethods)))
        {
            if (this.RequestHttpMethod.Equals(_enumName, StringComparison.InvariantCultureIgnoreCase))
            {
                this.IsWebDAVRequest = true;
                break;
            }
        }
    }
    #endregion

请建议我

0 个答案:

没有答案