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
What are virtual destructures?
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.
What is operator overloading in .net?
Explain how garbage collection works?
Please explain what is the difference between a class and an object?
What is the difference between asp.net & vb.net and explain architecture?
Difference between user groups and code groups
Do you know what's the difference between .net and laravel?
Is .net a compiler?
What are the different types of memory in .net?
Explain what is the difference between encrypting a password and applying a hashing?
Elements of CAS
Explain the difference between task and thread in .net?
What is cyclomatic complexity and why is it important?
How to spawn a thread?