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 are the advantages of .net?
What does mean by .net framework?
Interop Services?
Do you know what is the difference between an abstract class and an interface?
When we go for html server controls and when we go for web server controls?
Explain about the features and elements present in Visual studio.NET IDE?
What is the difference between web application and enterprise application?
Describe the use of following com+ services jit activation, queued components, object pooling.?
Explain the difference between the while and for loop.
Tell me what is a “jagged array”?
What is the difference between .net 2000 and .net 2005(features)? Which one is better?
If we write any code for DataGrid methods, what is the access specifier used for that methods in the code behind file and why?
What are three common acronyms used in .net, and what do they stand for?
How will you load an assembly which is not referenced by current assembly?
What are the important components of .net?