Thread Monitor class in c#
<p>In my c# application multiple clients will access the same server, to process one client ata a time below code is written.In the code i used Moniter class and also the queue class.will this code affect the performance.if i use Monitor class, then shall i remove queue class from the code.</p>

<p>Sometimes my remote server machine where my application running as service is totally down.is the below code is the reasond behind, coz all the clients go in a queue, when i check the netstatus -an command using command prompt, for 8 clients it shows 50 connections are holding in Time-wait...</p>

<p>Below is my code where client acces the server ...</p>

<pre><code>if (Id == "")
{
    System.Threading.Monitor.Enter(this);
    try
    {
        if (Request.AcceptTypes == null)
        {
            queue.Enqueue(Request.QueryString["sessionid"].Value);

            string que = "";

            que = queue.Dequeue();
            TypeController.session_id = que;
            langStr = SessionDatabase.Language;
            filter = new AllThingzFilter(SessionDatabase, parameters, langStr);
            TypeController.session_id = "";

            filter.Execute();
            Request.Clear();

            return filter.XML;
        }
        else
        {
            TypeController.session_id = "";
            filter = new AllThingzFilter(SessionDatabase, parameters, langStr);

            filter.Execute();
        }
    }
    finally
    {
        System.Threading.Monitor.Exit(this);
    }
}
</code></pre>
