Manish Pansiniya's Blog

.NET, C#, Javascript, ASP.NET and lots more…:)

Posts Tagged ‘Thread

Threading in ASP.NET

leave a comment »

You can do the same method which we can do in form based application. You need to be sure about the logic you are doing in the Thread.

Suppose you are accessing, Session in the thread and if thread is taking longer while the page code’s Response ended. Then you have problem as when response is ended the session variable of request is cleared.

So if you are accessing Request.Session , it will show null value after response is added.

You might call thread on page.init and in page load, you can call Join to wait for thread to complete and go ahead.

Below is sample code: I have passed context as thread’s parameter. It will be used fully as I used Join of thread. If I do not use Join then some of the variables is not available in context parameter. The conclusion is we can use thread same way but we need to be sure of page parameters/context parameters which we are passing to thread. That’s it!!!

protected void Page_Load(object sender, EventArgs e)
        Thread t = new Thread(new ParameterizedThreadStart(ref CallAnalyticsFunction));

        Response.ContentType = "image/gif";
        Response.AppendHeader("Content-Length", _imgbytes.Length.ToString());

[tweetmeme only_single=”false”]

Written by Manish

October 3, 2010 at 4:06 pm

ThreadManager (C# Threading class) is now on CodePlex

leave a comment »


I have uploaded ThreadManager class as new project on CodePlex. So it can be downloaded and used from there. It is really simple class to use with threadpool implementation. Already tested!!! :). Following is the URL

There are other projects for Threading on CodePlex website. You can search using ‘Threading’ and get the same.

EnJoY!!! ::):)

Written by Manish

April 7, 2009 at 6:30 pm

Threading in C# – ThreadManager class with ThreadPool

with 29 comments

Currently in our project, we are using a class for managing and running different worker thread. Also, the same class is used to queue threads that means the implementation of threadpool. The class is very useful and almost without bugs. If anyone wants the class, please comment on this post with your email.

 I have uploaded the class as codeplex project. Please goto the following site and download the same. Also, please report if there is any issue or improvement.

There are other projects for the Threading on CodePlex website. You can search using ‘Threading’ and get the same.

EnJoY!!! ::):)

Written by Manish

March 11, 2008 at 2:06 pm

Posted in .NET, .NET 3.0

Tagged with ,