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

Thread

P: n/a
Hello,
on the following line:
Thread startThread = new Thread(new
ThreadStart(plugin.StartPlugin(session)));

I got an error from the C# compiler:
[csc] c:\XXX\foo.cs(407,53): error CS0149: Method name expected

Column 53 is the T of ThreadStart.

I don't understand what is wrong. I' following the example given in the
MSDN doc, and from another book.

Thank you
Julien
Nov 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
julien <ju****@sobrier.net> wrote:
on the following line:
Thread startThread = new Thread(new
ThreadStart(plugin.StartPlugin(session)));

I got an error from the C# compiler:
[csc] c:\XXX\foo.cs(407,53): error CS0149: Method name expected

Column 53 is the T of ThreadStart.

I don't understand what is wrong. I' following the example given in the
MSDN doc, and from another book.


I suspect you're not *quite* following the example - you're calling a
method, rather than providing a method *name*. Normally you'd do:

Thread startThread = new Thread (new ThreadStart (plugin.StartPlugin));

Note that if your method takes a parameter, you can't use it as a
ThreadStart anyway.

See http://www.pobox.com/~skeet/csharp/t...rameters.shtml

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 17 '05 #2

P: n/a
Hi,

ThreadStart is a delegator of kind:

public delegate void ThreadStart();

Which means you have to provide its constructor a method with a return
type of VOID and does not receive any parameter.

and in addition, you have to provide only the method name, without the
().

In your code:
plugin.StartPlugin*(session)

you provide a parameter "session".

Eyal.

Nov 17 '05 #3

P: n/a
Jon Skeet [C# MVP] a écrit :
julien <ju****@sobrier.net> wrote:
on the following line:
Thread startThread = new Thread(new
ThreadStart(plugin.StartPlugin(session)));

I got an error from the C# compiler:
[csc] c:\XXX\foo.cs(407,53): error CS0149: Method name expected
... I suspect you're not *quite* following the example - you're calling a
method, rather than providing a method *name*. Normally you'd do:

Thread startThread = new Thread (new ThreadStart (plugin.StartPlugin));

Note that if your method takes a parameter, you can't use it as a
ThreadStart anyway.

See http://www.pobox.com/~skeet/csharp/t...rameters.shtml


Thank you

I finally decided to use a delegate that I call asynchronously. I think
the result will be the same: a new thread will be created for this call.

Julien
Nov 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.