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
How do you escape c#?
What is namespace explain with example?
Which is better python or c#?
What is difference between internal and protected internal in c#?
what is difference between destruct or and garbage collection ?
What is wrong with the sample program below?
What is the function of the not null constraint?
Is class reference type c#?
What is a interface in c#?
What are the Features in .net framework 1.1
explain the three services model commonly know as a three-tier application.
How do I edit a dll file?
Why do I get a "cs5001: does not have an entry point defined" error when compiling?
Differentiate between static class and singleton instance?
Can mvc be used for desktop applications?