Worker Thread not running and is returning a status of stopped!!!

J

Jim Macbeth

Hi,
We have some code that converts uploaded files from the uploaded type
(word doc etc) to Text and HTML.

The code is as follows:

// Create new thread with STA ApartmentState to invoke the COM objects
Thread cft = new Thread(new ThreadStart(convertFileThread));
cft.ApartmentState = ApartmentState.STA;
cft.Name = "ConvertTo" + destinationType;

convertState = ConvertState.Started;
sThreadMessage = "Could not start conversion thread";
cft.Start(); // Do it

cft.Join(300000); // Wait a maximum of convertTimeout milliseconds
(300000 miliseconds = 5 mins)

if (convertState == ConvertState.Completed)
{
return null;
}
else if (convertState == ConvertState.Running)
{
return string.Format("File conversion could not complete in {0}
seconds", (convertTimeout/1000));
}
else
{
sThreadMessage += "(convert state: "+convertState.ToString()+", thread
state: "+cft.ThreadState.ToString()+")";
return sThreadMessage;
}

This works fine on all servers we have installed the code on except one.

On that server the convertFileThread delegate function never starts. The
code runs through to the last else clause and returns
the following error:

Could not start conversion thread (convert state: Started, thread state:
Stopped)

Is there anything in asp.net that prevents client threads from starting?

Please note that this isn't my code. I have inherited it.

Anyway I am well confused so any help would be most appreciated.

The server having the problem and others that this code works fine on are
running .NET v1.0.3705

Thanks in advance,

Jim
 
S

Some Guy

Jim said:
Hi,
We have some code that converts uploaded files from the uploaded type
(word doc etc) to Text and HTML.
On that server the convertFileThread delegate function never starts. The
code runs through to the last else clause and returns
the following error:

Could not start conversion thread (convert state: Started, thread state:
Stopped)

Are you absolutley shure that thread does not start?
I do not see a code that generate this message.
Possibly there happend some not handled exception in the new thread and it
never finish. Than, logic based on some global variable "convertState"
makes bogus assumption "Could not start conversion thread".

Debugger should help you :)
 
J

Jim Macbeth

I wish the debugger would but locally it works fine so I can't reproduce the
problem.

Jim
 
D

Dave

Have you checked the event log for error messages?

This is unlikely but....perhaps the server does not have sufficient rights
to start a thread.

If you could post a snippet of the code the thread is supposed to execute it
might shed more light on this. Another thing you can try is to run DbgView
on the server machine to see if any debug messages are being generated.
 

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

Top