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
What does static mean in c sharp?
What is difference between continue and break in c#?
What is the default value of boolean variable?
Can a dictionary have duplicate keys c#?
Which one is trusted and which one is untrusted?
Which controls do not have events?
what is the difference between a struct and a class in c#?
Can we call server-side code (c# or vb.net code) from javascript?
What is the difference between “out” and “ref” parameters in c#?
If a method's return type is void, can you use a return keyword in the method?
What is binding in c#?
What is the process of delegation?
Is string mutable in c#?
What are the value types in c#?
When should I use static in C#?