What should my thread signature look like if I want to return a String?

  • Thread starter Thread starter chance
  • Start date Start date
C

chance

I want my thread method to return a String. However, the compiler is
saying that the best overloaded method match for
System.Threading.Thread has some invalid arguments. Not sure what I
need to change here.

public String generateNOV(string xmlParms)
{
Thread novThread = new Thread(delegate()

tia,
chance.
 
I want my thread method to return a String. However, the compiler is
saying that the best overloaded method match for
System.Threading.Thread has some invalid arguments. Not sure what I
need to change here.

public String generateNOV(string xmlParms)
{
Thread novThread = new Thread(delegate()

tia,
chance.

The delegate needs to follow ParameterizedThreadStart's signature
which is void func(object state);
 
I want my thread method to return a String.

A .NET Thread cannot "return a string", or any value for that matter.

If you want a thread to do some processing and emit a string, you need to
define some mechanism by which the string is explicitly set somewhere else
and then can be retrieved by whatever other thread wants to use the string.

Pete
 
Hi,


A thread cannot have a return value.

You have to store the value in a variable accesible from both the creator
and the thread.
The creator should not be able to access it until the thread had set the
value in the variable though.
 

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

Back
Top