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


Please Help Members By Posting Answers For Below Questions

What is the difference between odbc and ado?

762


How anonymous method is different from a lambda expression?

729


What is singlecall activation mode used for in .net?

767


What is assembly in .net?

788


can any one tel me the complete Testing Procedure of any one simple PROJECT i mean either web/windows based application?

1670


Can a try block have more than one catch block?

814


What is close method? How its different from finalize and dispose?

735


Different levels of priority provided by .net.

810


What is the difference between .net 2000 and .net 2005(features)? Which one is better?

735


What is Flyout Design Pattern in .NET?

863


Tell us what is heap and what is stack?

773


How we can achieve Connection pooling in .Net?

846


Explain what are the deferred execution and the immediate execution in linq?

762


What is loosely coupled solution in.net?

754


What is .net standard?

794