iis 7 - Identity.Name is disposed in a IIS7 Asp.NET MVC application Thread -


I have created the smallest demo project to clarify my problem. You can download the source

Visual Studio 2008, .NET 3.5, IIS 7, Windows 7 Ultimate 32 bits IIS website is configured only for Windows authentication in an integrated pipeline app pool (default app pool).

Here's the problem I have an ASP.NET MVC 2 application in an action, I see a thread starting return.

Thread is working on this ... but it needs to reach the thread. Current Principal. Identity .name

BANG

The worker process IIS7 stops I have a window that says: "Visual Studio Bus-In-Time Debugger is an uncontrolled exception ('System. Object.DisposedException ') happened in w3wp.exe [5524] "

I checked with the debugger and thread. Custom Principal. Identity is valid, but the name property is settled.

If I wait a long time in action before returning to the scene, then the thread can identify it and its work. The name is not disposed, so I think that when the scene is returned the name is settled.

To discuss, here's the code that runs the thread (but you can also download the demo project. The link is at the top this post):

  () {Const int SECTOWAIT = 3; // SECTOWAIT second long wait = DateTime.Now teak + (timespace.TextersSecond * SECTOWAIT); While (datetime.now.Ticks & lt; = end) release; // Check current Principal Bang !!!!!!!!!!!!! Var Username = Thread Current Principal. Recognise. Name; }  

This thread is the starting code

  Public Zero Start () {Thread Thread = New Thread (New Parameterated Thread Start (Threadproc)); Thread.SetApartmentState (ApartmentState.MTA); Threads Name = "test refreshed"; Thread.Start (this); } Static Zero Threadproc (object o) {try {Builder Builder = (Builder) o; Builder.Run (); } Hold (pre-ex) {throw; 

"Itemprop =" text ">

If you start a new thread, it will not use the same HTTPPontact (it will move to another context).

Take a look here ...

Your Dwarves will get an object (which is your HTTP Consort. Content)

In addition, you should always wait for 3 seconds

RedSleep (3000); - Milliseconds.

It's better than when you have a loop ... less code, right? :)


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -