Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why use ThreadStart?

Can somebody please clarify why we use ThreadStart?

new Thread (new ThreadStart (Update)).Start(); -Versus-
new Thread (Update).Start(); // Seems more straightforward

private void Update() { }
like image 754
Dave Avatar asked May 19 '11 10:05

Dave


1 Answers

Can somebody please clarify why we use ThreadStart?

You don't have to. If you do, only you can say why...

Since C# 2, method groups (i.e. references to a method via its name) are implicitly convertible to delegates with the same signature. Since the Thread constructor takes a ThreadStart, you can pass it a method group with the same signature as ThreadStart.

like image 55
Thomas Levesque Avatar answered Nov 15 '22 17:11

Thomas Levesque