How do you create threading in .NET? What is the namespace
for that?

Answers were Sorted based on User's Feedback



How do you create threading in .NET? What is the namespace for that?..

Answer / 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

How do you create threading in .NET? What is the namespace for that?..

Answer / guest

System.Threading.Thread

Is This Answer Correct ?    9 Yes 5 No

Post New Answer

More Dot Net General Interview Questions

How many types of generations are there in a garbage collector?

0 Answers  


What are nullable types in .NET

0 Answers   TryTechnicals Pvt Ltd,


What is loosely coupled solution in.net?

0 Answers  


Please explain what is the .net framework and how does it work?

0 Answers  


What is garbage collection and how it works. Provide a code example of how you can enforce garbage collection in .net?

0 Answers  






How is a managed code executed?

1 Answers  


Explain garbage collection?

0 Answers  


What is the difference between VB and VB.NET?

2 Answers  


Compare & contrast rich client (smart clients or windows-based) & browser-based web application

0 Answers  


What is an Exception? How many exceptions exist in Dot net and explain them?

2 Answers   CSC, TCS,


What is meant by localization?

0 Answers  


what is prototype design pattern in .net

0 Answers   Infosys,


Categories