How do you create threading in .NET? What is the namespace
for that?
Answer Posted / ashish omar
The namespace to use multithreading in .Net is "using
System.Threading;"
Live Example to demonstrate how multithreading can be
achieved in .Net.
C#
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
namespace DataAccess
{
class Thread_Excesise
{
public void Child_Thread()
{
for (int i = 0; i < 10; ++i)
{
Console.WriteLine(" Child_Thread with
Count" + i);
Thread.Sleep(100);
}
}
static void Main(string[] args)
{
Thread_Excesise inst = new Thread_Excesise();
for (int i = 0; i < 10; ++i)
{
Console.WriteLine("Main Thread");
Thread t = new Thread(inst.Child_Thread);
t.Start();
Thread.Sleep(1000);
}
}
}
}
Code posted by "Ashish Omar"
| Is This Answer Correct ? | 5 Yes | 0 No |
Post New Answer View All Answers
What does jit compilation do in .net?
What is delegation in .net?
What is meant by managed and unmanaged code?
What is DTS and explain the purpose of it?
What is the difference between imperative and interrogative code?
What does stateless mean?
which methos do you invoke on the dataadapter control to load your generated dataset with data?
What is manifest in .net?
What is the difference between boxing and unboxing?
What does jit do?
What is different between webusercontrol and in webcustomcontrol?
what is machine key error in .NET how can we solve it?
What is operator overloading in .net?
Explain about .NET services?
Explain the difference between public and static modifiers?