By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,238 Members | 1,804 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,238 IT Pros & Developers. It's quick & easy.

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

P: n/a
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.

Apr 2 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On Apr 2, 8:41 am, "chance" <cha...@crwmail.comwrote:
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);

Apr 2 '07 #2

P: n/a
On Mon, 02 Apr 2007 05:41:37 -0700, chance <ch****@crwmail.comwrote:
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
Apr 2 '07 #3

P: n/a
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.

"chance" <ch****@crwmail.comwrote in message
news:11*********************@y66g2000hsf.googlegro ups.com...
>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.

Apr 2 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.