Asynchronous Pages In The Framework - Where Are The Other Threads And How Is It Reattached

Apr 4, 2010

IIS has a limited set of worker threads waiting for requests. If one request is a long running operation, it will block that thread. This leads to fewer threads to serve requests. Way to fix this - use asynchronous pages. When a request comes in, the main worker thread is freed and this other thread is created in some other place. The main thread is thus able to serve other requests. When the request completes on this other thread, another thread is picked from the main thread pool and the response is sent back to the client.

1) Where are these other threads located? Is there another thread pool? 2) IF ASP.NET likes creating new threads in this other thread pool(?), why not increase the number of threads in the main worker pool - they are all running on the same machine anyway? I don't see the advantage of moving that request to this other thread pool. Memory/CPU should be the same right?3) If the main thread hands off a request to this other thread, why does the request not get disconnected? It magically hands off the request to another worker thread somewhere else and when the long running process completes, it picks a thread from the main worker pool and sends response to the client. I am amazed...but how does that work?

View 4 Replies


Similar Messages:

When To Use PageAsyncTask (Asynchronous Pages)?

Mar 7, 2010

From my understanding from reading about ASP.NET asynchronous pages, the method which executes when the asynchronous task begins ALWAYS EXECUTES between the prerender and the pre-render Complete events. So because the page's controls' events run between the page's load and prerender events, is it true that whatever the begin task handler (handler for BeginAsync below) produces, it can't be used in the controls' events? So for example, if the handler gets data from a database, the data can't be used in any of the controls' postback events? Would you bind data to a data control after prerender?

PageAsyncTask pat = new PageAsyncTask(BeginAsync, EndAsync, null, null, true);
this.RegisterAsyncTask(pat);

View 2 Replies

Web Forms :: Use For Asynchronous Pages?

Feb 17, 2010

I use for 5-Layer architecture and asynchronous Pages in my application(Presentation Layer,Caching Layer,Businnes Logic Layer,Transaction Layer,Data Access Layer) .I want to cancel Asynchronous Method if data was in cache.

View 3 Replies

AJAX :: UpdatePanel And Asynchronous Pages ?

Apr 16, 2010

Could ASP.NET AJAX UpdatePanel could be used in ASP.NET asynchronous pages ? Could Page Methods be made asynchronous also ?

View 4 Replies

Sending Asynchronous Emails From Web Pages?

Sep 3, 2010

Here is my situation and hopefully someone could guide me in the right direction.I have a shared or static class in my website (App_Code folder) which has static methods to send emails asychronoulsy. So whenever there is an exception in any of my pages or classes I call these methods to send an email to support asynchronously. Now when there is an exception in a page, to route that exception asynchronously I need to have Async = "true" for that page. I have more than 50 pages and I don't want to set Async= "true" on every page as I read that it affects performance.So I was wondering if there is any way I could send emails asynchronously without having to set async = "true" on every page.

View 7 Replies

How To Manage Threads In A C# Web App

Jan 6, 2011

I built a little web application that displays charts. I was thinking that it might be useful for the superuser of the app to do a complete data refresh, however this process takes around 10 minutes to complete. I was thinking perhaps the user could click a button that would start off a new thread to do a data refresh and subsequent clicks would kill the thread and restart the data population process. The user would then be free to browse about the site and view the charts as their data is populated.

Is there a simple method of accomplishing something like this?

View 3 Replies

Trying To Get A Better Handle On How Threads Work?

Aug 20, 2010

I'm trying to get a better handle on how threads work in ASP.NET, so I have a test site with a few pages, and I have a test WinForms client that creates 40 roughly concurrent requests to the test site. The requests take about 5-10 seconds to complete--they call a web service on another server. When I run the test client, I can use Fiddler to see that the requests are being made concurrently. However, when I look at Performance Monitor on the web server, with counters "ASP.NET Apps v2.0.xxx/Requests Executing", "ASP.NET/Requests Current", "ASP.NET Requests Queued", these counters never display more than 2.

This is the case regardless of whether the test page I'm requesting is set up with Async=True and using the Begin/End pattern of calling the web service, or if it's set up to make the call synchronously. Judging by what I see in Fiddler, I would think I should be seeing a total of 40 requests in one of those states, but I don't. Why is that? Do these counters not mean what I think they mean?

View 1 Replies

How To Share Data Between Threads

Nov 1, 2010

In the main thread I open a new thread that gets the number of new messages of user (takes about 5 secs) and this second thread should save the number in some place.

In the main thread I should check the "some place" and if the value exists I display it on the page.

Where can I save the value from the second thread to read it from the main one? This value is unique per user so I can't use static field.

View 3 Replies

C# - AsParallel() - With More Than 2 Threads In Parallel?

Feb 21, 2011

I have a method that I call 8 times with different parametres.I use

AvailableYears.AsParallel()
.Select<Int32,DateUsedByThread>(x => GetDataForYearWorker(x,CIF))
.ToList();

GetDataForYearWorker gets the response from a webservice synchronously. It uses very little computing power on my asp.net application, but it ussualy takes 3-5 sec for each webservice response. Because the calls to the webservice are independent of eachother, I want to make tham all at the same time. But it looks like only 2 threads can run at the same time. Why is this and how can I have 8 threads working at the same time?

View 1 Replies

C# Execute 2 Threads Simultaneously?

Feb 27, 2011

I am trying to reproduce a threading error condition within an HTTP Handler.

Basically, the ASP.net worker procecss is creating 2 threads which invoke the HTTP handler in my application simultaneously when a certain page loads.

Inside the http handler, is a resource which is not thread safe. Hence, when the 2 threads try to access it simultaneously an exception occurs.

I could potentially, put a lock statement around the resource, however I want to make sure that it is infact the case. So I wanted to create the situation in a console application first.

But i cant get 2 threads to execute a method at the same time like asp.net wp does. So, my question is how can you can create 2 threads which can execute a method at the same time.

Edit:

The underlying resource is a sql database with a user table (has a name column only). Here is a sample code i tried.

[TestClass]
public class UnitTest1
{
[TestMethod]
public void Linq2SqlThreadSafetyTest()

[Code]....

View 1 Replies

Wcf - Update Value In TextBox From Other Threads?

Mar 5, 2011

I'm using ASP.NET 4.0 on IIS7.5 and WCF Callback technique. I have no problem with callback. The wcf service can fire callback method in web client but it seems it's on another thread with the UI thread.

public partial class _Default : System.Web.UI.Page, IServiceCallback
{
private IService proxy = null;
private static TextBox _textBoxtest;
protected void Page_Load(object sender, EventArgs e)

[Code]....

how to update my textBox from callback event.

View 2 Replies

Iis - Web Garden - Max Worker Threads?

Oct 5, 2010

I'm investigating some performance improvements that can be made to our web server and ASP.NET application.This page contains a few things that we can do.We currently have two worker processes running as a garden. Do each of these worker processes have their own ASP.NET threadpool? Or do both of these worker processes share a single threadpool and the max number of worker threads is shared across these processes?This post seems to suggest that the two processes share a common ASP.NET threadpool. All w3wp.exe threads do is take requests from HTTP.SYS queue, process it, and hand the request toASPNET_ISAPI.DLL, who then deposits those requests into the ASP.Net request queue, and the ASP.Net threadsBut this post suggests that each worker process contains their own ASP.NET threadpool. Each process (w3wp.exe) has its own CLR thread pool which has the configured maxworkerthreads value (20 default).

View 1 Replies

Working With Threads On Pageload?

Feb 15, 2011

When my asp.net page loads,it needs to get data from 2 webservices.I want to make the data retrieval processes work concurently.How can I do this and update Label1 with the text result from WS1 and label2 with the result from WS2?I don't know how the code should look like in order to be able to update the controls on the page.

View 1 Replies

Asp.net - Is HttpModule Shared Among Working Threads

Apr 11, 2010

Do I have to lock access to instance members?

public class HttpModule : IHttpModule
{
//...
Dictionary<int, int> foo;
void UseFoo(int a, int b)
{
foo[a] = b;
}
}

View 2 Replies

Exception Handling In Background Threads?

Jun 15, 2010

When I do ThreadPool.QueueUserWorkItem, I don't want unhandled exceptions to kill my entire process. So I do something like:

ThreadPool.QueueUserWorkItem(delegate() {
try { FunctionIActuallyWantToCall(); }
catch { HandleException(); }
});

Is this the recommended pattern? It seems like there should be a simpler way to do this. It's in an asp.net-mvc app, if that's relevant.

View 1 Replies

Security :: CurrentPrincipal In Background Threads?

Dec 20, 2010

I have a web application hosted in IIS 7.5 and expose its functionality using web services. The web application has state the the first thing I do is to call a web service method to start it all up. As a consequence several threads are created and these threads run until the system is stopped. All recycling of application pools and such is disabled! To access the web services the calling client must authenticate (using basic auth and local windows users). Thus, an incoming request has the CurrentPrincipal set. The logging subsystem is setup to tag all log messages with the current principals identity name and this works just fine for code that runs on an the thread of on incoming request. But, it doesn't work at all for all of my background threads. The current principal is still set in these threads but the identity objects name has been disposed. Why is this? What can I do to fix this. I would really like to get all log messages tagged with the current principal. It also seems impossible to detect if the identity name instance has been disposed without trying to access it and catch the exception which is highly annoying.

View 2 Replies

Threads Inside A Foreach Loop In C#?

Jan 5, 2010

I had the following code to send different mails to differnt users in my asp.net web application

foreach (DataRow dataRow in dataTable.Rows)
{
sendMails();

[code]...

View 8 Replies

Installation :: Set Default Culture For New Threads In Asp?

Mar 1, 2011

ASP.NET 2.0

We have an old app we are moving to a new server and the dates are screwing up (we are in England dd/MM/yyyy) on an assynchronous thread.

Googling it appears that each thread needs to be set to a specific culture otherwise it defaults to the 'OS default locale'. We don't want to change the code so looks like we need to change the os default locale.

Just to be completely clear - does a new thread in asp.net default to the app.config setting (no), machine.config settings (?), app pool account settings (Network Service in our case), Local Service or the Local System account locale settings? Can the default be changed through the Administration tab in regional setting (WS2008)?

Second question, when looking at Environment.UserName, it is showing the server name (xxxx$) rather than Network Service (which is running the app pool). Why is this?

Also, do we need to worry about Input Language, or just Format (locale)?

Is it possible for the Welcome Page to be showing as English (United Kingdom) but the system accounts to actually be English (United States)?

View 1 Replies

How To Generate ActionLink Inside Threads

Sep 13, 2010

I've got a thread that sends emails around. I need to generate ActionLinks as part of the content of the email so the user can click on the link and be redirected to the website, exactly to the required page. I tried to instantiate a UrlHelper class and use it's Action method to generate the link but since threads don't run within the context of any request I get exceptions at the time of generating the ActionLink.

View 2 Replies

Multithreading - How Are Threads Tied To Requests Through Http.sys, IIS

Jan 29, 2011

I'm currently reading a lot about node.js. There is a frequent comparison between servers using a traditional thread per request model (Apache), and servers that use an event loop (Nginx, node, Tornado).

I would like to learn in detail about how a request is processed in ASP.NET - from the point it is received in http.sys all the way up to it being processed in ASP.NET itself. I've found the MSDN documentation on http.sys and IIS a little lacking, but perhaps my google-fu is weak today. So far, the best resource I have found is a post on Thomas Marquardt's Blog.

Could anyone shed more light on the topic, or point me to any other resources?

View 1 Replies

How To Best Debug The Creation Of Unwanted Threads In Web Application

Dec 7, 2010

After an IISRESET on my public facing webserver, the initialization of my app seems correct. That is, in the Application_Start event I launch a new "email" thread whose purpose is to sleep until the configured time, upon "waking" produce a report and email it to my administrative user(s) and go back to sleep until the configured duration elapses at which time, the report is created again and emailed out. I am currently configured to start at 1900 and produce a new report every 12 hours.

As time marches on with this production site, however, something is causing an "extra" thread to be created. This, in turn, results in a duplicate report being emailed. While the problem is benign enough, I'd like to clean this up if possible. Here's a snippet:

[code]....

The above code seems to work fine (like I stated, after an IISRESET, I see the one logged event from the Application_Start event followed by the log entry from my "email" thread: "EmailThread will sleep for nnn minutes...etc.". But somehow (over time) I am getting another instance of the EmailThread thus producing 2 reports instead of just one at the scheduled "wake time".

In the IIS application pool assigned to this website, I have the following settings:

- Recycle worker processes (in minutes) is UNCHECKED
- Recycle worker process (number of requests) is UNCHECKED
- Recycle worker process (at various times) is UNCHECKED / nothing specified
- [Idle timeout] Shutdown worker process after being idle for (time in minutes) is UNCHECKED

I have noticed that the Application_Start event can be entered again (in one case roughly 38 minutes after the first time) which causes my code to run again and create another [and unwanted] thread.

View 2 Replies

Web Forms :: How To Synchronize Users Requests / Threads

Feb 6, 2011

I have what I consider a pretty complex situation that I am not sure if it can even be accomplished via an ASP.NET web application. (I am using aps.net 4.0) But what I want to do is design a "online auction site" that can handle many autions running at the same time. So I can only imagine eBay and all the other millions of auction sites out there are all doing this someway or another. My biggest concern is that I want to make sure the design here to make the site as effiecent as possible. Here is specifically what I am trying to figure out.

I think I need to create an object (per active auction) that stays in memory for the life of the auction. This object would have at least the following information:

Aution ID, time remaining, highest bidder id, bid price, Thread Control Variable, etc...

Now here is the tricky part that I think is vital for auction sites. Lets say you have 500 users on my website that are all watching the same auction and it is getting down to the last second of the auction and they all click to place a bid at the same time. Keep in mind this may also be at the same time hundreds of other users are placing bids for other auctions going on all at the same time.

How do I get all these requests (bids), for a single auction, lined up so that they are processed "one at a time"? But some how I need to be able to make all requests wait in a queue until it is their "turn" then I would need to be able to update the in memory object, write a record into a SQL database and then begin returning information back to each user.

Based on other development languages I have used in the past I know their were objects that I could create that could be used to get multiple threads to run in order (in other words syncronized). Usually it would be a case where I would be listening on a server socket and could do something like ThreadVariable.Lock, <process the request>, thenThreadVariable.Unlock. What that would do, is force all threads that tried to call ThreadVariable.Lock to wait until no other threads had the variable locked then it could proceed. Obviously the code it processes between the lock and unlock should be as quick and effecient as possible so it does not create a major traffic jam.

Because my thinking is this "object" I am referring to as being in memory, most likely will play a big role in answering the question about getting the requests in a "one at a time" situation it may be the focus of the question is more like how would I create "an object" and store it in memory to be quickly and easily accessed?

And even more generically does this even sound like I am on the right track

I think the topic of "communication to and from users" will need to be a completly different thread.

View 5 Replies

State Management :: Wcf Service Billing / Threads?

Feb 18, 2011

I have a wcf service which is exposed publicly to the authorized users.

User1 uses service1 - it checks for validuser and valid subscription for noofcallsallowed per user.

I have a logic return as:

IsSubscriptionValid(userId)
{
TrackUsage(userId);
}

while User1 uses service1:

Thread1 comes to checks for valid subscription and update the usage.In the mean thread2 comes in for the same user which check for valid subscription, and thread1 donot update the usage yet.

So its a wrong call for thread 2?

View 1 Replies

Configuration :: WebGarden Or Maximum Number Of Threads?

Jan 6, 2011

My ASP.NET MVC 2.0 web application does not maintain any session state and My production machine has n (>1) core, .NET 4.0, IIS 7.5 Integrated mode.For increased performance, I am curious if I should increase the max concurrent threads in thread pool to 12*n or should I keep the max concurrent threads as 12 but assign n worker process (w3wp.exe) to my application pool. What are the pros and cons of one over another?

View 1 Replies

C# - Shared Messaging Queue For Multiple Worker Threads In IIS?

Nov 1, 2010

I'm currently trying to interface our new intranet (ASP-MVC) with the web front end of our pager system. The pager system's front end is about 10 years old, poor interface and no documentation. To do this I have the form on the intranet post to the server, our server then sends an HTTP POST to the pager server that mimics what its own form sends.

While testing this for overloading (we sent about 10 messages almost concurrently) the pager server crashed, as the system is a black box and the only difference we noticed was the concurrent POSTs the least we can do is try to prevent this happening.I want to have all messages go into a queue that sends at most once every 5-10 seconds but I'm not sure how to implement this,

I didn't specify this earlier but the process should be synchronous from the point of view of the browser, ie webserver gets the http POST request from the browser, message is put into the queue, message is sent from the queue, webserver sends http response to the browser. This is not a high volume service and I expect simultaneous requests to be rare so response will be near instantaneous, it is more of a throttle to prevent potential issues with concurrent requests.

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved