Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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 are virtual destructures?

1064


Write a program to create a user control with name and surname as data members and login as method and also the code to call it.

919


What is operator overloading in .net?

1034


Explain how garbage collection works?

1003


Please explain what is the difference between a class and an object?

1033


What is the difference between asp.net & vb.net and explain architecture?

1065


Difference between user groups and code groups

2363


Do you know what's the difference between .net and laravel?

1108


Is .net a compiler?

1030


What are the different types of memory in .net?

1067


Explain what is the difference between encrypting a password and applying a hashing?

1103


Elements of CAS

2175


Explain the difference between task and thread in .net?

935


What is cyclomatic complexity and why is it important?

2369


How to spawn a thread?

1016