Thread not starting

G

Gürkan Demirci

Hi,

i am building an ASP.NET web project with J#.
I have the problem, that a Threads run() method isn't
invoked after Thread.start().
It's working in one project, but it isn't in an other one.

Are there any settings involved in this ?


regards,

gürkan
 
G

Gürkan Demirci

The code is realy simple to check the behaviour.

static public volatile boolean isStarted = false;

static public void run()

{

isStarted = true;

}

protected void Application_Start(Object sender, System.EventArgs e)

{

System.Threading.Thread t = new System.Threading.Thread(new
System.Threading.ThreadStart(run));

t.set_Priority(System.Threading.ThreadPriority.Lowest);

t.Start();

while ( !isStarted );

}

run() is never been invoked. The applications hangs in while(isStarted).

regards,

gürkan
 
A

Alvin Bruney - ASP.NET MVP

that won't give you the results you are looking for because the application
start event only fires once. put the code in the page load event of the
webpage or leave the code where it is and re-start IIS. it should work then

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ www.lulu.com/owc
Forth-coming VSTO.NET - Wrox/Wiley 2006
 
C

Chris Botha

My guess would be this - you set the thread's priority to lowest then you go
into a tight loop in the main thread. Should you sleep for a milli second or
two in the main thread inside the loop, then the thread should be able to
execute.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top