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

Explain what is an application domain?

532


What is the base class of Button control in .NET?

613


I want to serialize instances of my class. Should I use xmlserializer, soapformatter or binaryformatter?

533


Explain the use of activex control in .net?

572


Can you write a class without specifying namespace?

584






Types of evidence in .net with context to CAS

1645


What is different between webusercontrol and in webcustomcontrol?

540


What operating systems does the .net framework run on?

554


What is meant by globalization?

571


What is the single responsibility principle?

569


What is Finalizer in .NET define Dispose and Finalize ?

574


what is prototype design pattern in .net

570


Do you know what are three common acronyms used in .net, and what do they stand for?

561


What is an anonymous method?

527


What are the differences between com architecture and.net architecture?

555