Created
November 12, 2017 13:33
-
-
Save luisdeol/1ce0adea30a706ceda8932952ebdfa27 to your computer and use it in GitHub Desktop.
Using Parametrized ThreadStart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace MultiThreadingExamples | |
{ | |
class ParametrizedThreadStartExample | |
{ | |
public static void UltraCoolMethod(object o) | |
{ | |
for (var i = 0; i < (int)o; i++) | |
{ | |
Console.WriteLine($"Execution Thread Nº {i}"); | |
Thread.Sleep(0); | |
} | |
} | |
static void Main(string[] args) | |
{ | |
Thread theThread = new Thread(new ParameterizedThreadStart(UltraCoolMethod)); | |
// You can do it Implicitly as well | |
// Thread theThread = new Thread(UltraCoolMethod); | |
theThread.Start(10); | |
theThread.Join(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment