ParameterizedThreadStart required to start thread with one parameter- Csharp.Net
Q. Which delegate is required to start a thread with one parameter?- Published on 31 Aug 15a. ThreadStart
b. ParameterizedThreadStart
c. ThreadStartWithOneParameter
d. None of the above
ANSWER: ParameterizedThreadStart
ParameterizedThreadStart is a delegate that refers to a method that have single parameter.
Example:
class Program
{
static void Main(string[] args)
{
ParameterizedThreadStartts = new ParameterizedThreadStart(Counting);
Thread obj = new Thread(ts);
obj.Start("careerride");
}
static void Counting(Object obj)
{
stringstr=(string)obj;
Console.WriteLine("Welcome at "+str);
for (int i = 1; i <= 10; i++)
{
Console.WriteLine("Count: {0}", i);
Thread.Sleep(10);
}
}
}