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 is difference between a type and class?
What is an assembly in .net?
What is system console writeline in c#?
Is 0 an unsigned integer?
Give an example of a ctype.
What is the difference between new and override in c#?
Can a method be sealed in c#?
Illustrate serialization?
Can class inherit from struct c#?
What is the difference between interface and functional interface?
What is private static in c#?
Write a program to find the angle between the hours and minutes in a clock
Is c# 8 released?
What's the difference between a static method and a non static method c#?
Is string passed by reference in c#?