For Programmers: Free Programming Magazines  


Home > Archive > ASP .NET > September 2005 > Thread not starting









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Thread not starting
Gürkan Demirci

2005-09-29, 7:57 am

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


Landley

2005-09-29, 7:57 am

Please post your code and I'll have a look.

L.

"Gürkan Demirci" <fake_email@host.de> wrote in message
news:OjlHe%23NxFHA.3756@tk2msftngp13.phx.gbl...
> 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ürkan Demirci

2005-09-29, 7:57 am

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



"Landley" <news@creations-software.co.uk> schrieb im Newsbeitrag
news:%23d5pBnOxFHA.2848@TK2MSFTNGP15.phx.gbl...
> Please post your code and I'll have a look.
>
> L.
>
> "Gürkan Demirci" <fake_email@host.de> wrote in message
> news:OjlHe%23NxFHA.3756@tk2msftngp13.phx.gbl...
>
>



Alvin Bruney - ASP.NET MVP

2005-09-29, 7:01 pm

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
-------------------------------------------------------



"Gürkan Demirci" <fake_email@host.de> wrote in message
news:unubkzOxFHA.2976@TK2MSFTNGP10.phx.gbl...
> 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
>
>
>
> "Landley" <news@creations-software.co.uk> schrieb im Newsbeitrag
> news:%23d5pBnOxFHA.2848@TK2MSFTNGP15.phx.gbl...
>
>



Chris Botha

2005-09-29, 9:57 pm

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.

"Gürkan Demirci" <fake_email@host.de> wrote in message
news:unubkzOxFHA.2976@TK2MSFTNGP10.phx.gbl...
> 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
>
>
>
> "Landley" <news@creations-software.co.uk> schrieb im Newsbeitrag
> news:%23d5pBnOxFHA.2848@TK2MSFTNGP15.phx.gbl...
>
>



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2010 codecomments.com