Write the sample code for threading in c# .net..
Answer Posted / alcheringa
using system.threading;
// this is the function that we want to invoke in a new
thread
static void doit()
{
for (int i=0 ; i < 10; i++)
{
console.writeline("doing somethin");
}
}
// this is the main fucntion
public static void main()
{
// threadstart is the delegate
// we need to pass the method, ts accept's method name as
the parameter
threadstart ts=new threadstart(doit);
// this is how we define a new thread
thread tr=new thread(ts);
// we invoke the thread
tr.start()
conosle.readline();
}
Is This Answer Correct ? | 22 Yes | 10 No |
Post New Answer View All Answers
Can constructor have return type c#?
What do u mean by thread safe?
Is linkedhashset synchronized?
What is hashset c#?
Explain the different types of delegates used in c#.
What is difference between array and arraylist c#?
Write the difference between TypeOf and GetType?
What is a verbatim string literal and why do we use it?
What is protected internal modifier in C#?
Int map to which .net types?
What are methods in C#?
What is difference between array and arraylist in c#?
What are extension methods and where can we use them?
What is a thread c#?
What is querystring in c#?