.NET ParameterizedThreadStart wrong return type .NET ParameterizedThreadStart wrong return type multithreading multithreading

.NET ParameterizedThreadStart wrong return type


If you read the error message, you'll see that the problem is that the method has the wrong return type.

Specifically, your UploadFile method returns bool, but the ParameterizedThreadStart delegate returns void.

To fix this, change the UploadFile method to return void, and change all of its return xxx; statements to return;.

Alternatively, you could wrap UploadFile in an anonymous method, like this:

Thread ftpUploadFile = new Thread(delegate { ftp.UploadFile(e.FullPath); });ftpUploadFile.Start();


You are not supposed to return anything from your method. Make the return type void - as documented:

public delegate void ParameterizedThreadStart(Object obj)

If you need to know results from your method you need to look into Thread Synchronization.


Use an anynomous delegate like so:

bool result = false;    ThreadStart s = delegate{    result = UploadFile(ftp.UploadFile);};Thread t = new Thread(s);s.Start();s.Join();// now you have your result    if (result){ // do something useful}