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 is Flyout Design Pattern in .NET?
What's wrong with a line like this? Datetime.parse(mystring);
If any body working in Infosys, please can u give me the referense to that company because i hered that their is openings for freshers with referal..
If we write any code for DataGrid methods, what is the access specifier used for that methods in the code behind file and why?
How to instantiate a delegate?
With these events, why wouldn't microsoft combine invalidate and paint, so that you wouldn't have to tell it to repaint, and then to force it to repaint?
How to create multiple inheritance in c#, with example?
What is "common language specification" (cls) in .net?
How do you create threading in.net?
Is .net core the future?
What is the root class in .net?
What are the authentication methods in .net?
Explain what are an object and a class?
How will you make .NET programs work in Linux ?
What is .net3.5?