Main Site Documentation

Quick Question about NETMF threading


#1

for some reason, my code wont accept


string message = "someTestStuff";
Thread t = new Thread (Handle);
  t.Start (message);

where the Handle method is:


public static void Handle(string message)
{
//do whatever
}

it forces you to use a lambda expression i.e.


string message = "someTestStuff";
Thread t = new Thread (()=> Handle(message));
  t.Start ();

why is this?


#2

I think you have to because your thread method takes arguments?


#3

To expand on what Gus said: NETMF’s version of the Thread class doesn’t allow you to pass an argument to the thread like its big brother from the full framework (see http://msdn.microsoft.com/en-us/library/ee436362.aspx). :slight_smile:


#4

aha! I see… but thank you!