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
Explain what is an application domain?
What is the base class of Button control in .NET?
I want to serialize instances of my class. Should I use xmlserializer, soapformatter or binaryformatter?
Explain the use of activex control in .net?
Can you write a class without specifying namespace?
Types of evidence in .net with context to CAS
What is different between webusercontrol and in webcustomcontrol?
What operating systems does the .net framework run on?
What is meant by globalization?
What is the single responsibility principle?
What is Finalizer in .NET define Dispose and Finalize ?
what is prototype design pattern in .net
Do you know what are three common acronyms used in .net, and what do they stand for?
What is an anonymous method?
What are the differences between com architecture and.net architecture?