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

Answer Posted / sabu

using System;
using System.Threading;
namespace ConsoleApplication1
{
class Class1
{
static void PrintHelloFromThreadName()
{
Console.WriteLine("Hello, from thread {0}",
Thread.CurrentThread.Name); // {0}
}
public void ThreadStart()
{
PrintHelloFromThreadName();
}
static void Main(string[] args)
{
Thread.CurrentThread.Name = "Main thread";
Class1 obj = new Class1();
Thread thread = new Thread(
new ThreadStart(obj.ThreadStart));
thread.Name = "Forked thread";
thread.Start();
PrintHelloFromThreadName();
}

Is This Answer Correct ?    4 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the use of Treeview control?

823


What is operator overloading in .net?

790


What are the different types of Classes in .NET?

819


What are the types of jit?

795


What is .net and .net framework?

810


What are the features of dot net?

768


Explain the difference between garbage collections in .net 4.0 and earlier versions?

720


What are the new 2.0 features useful for?

840


Explain is the jit an interpreter?

762


What is singleton activation mode in .net?

874


Please explain what are an inheritance, polymorphism, and encapsulation?

796


What are the differences between an interface and an abstract class in .net?

733


How to manage pagination in a page using .net?

756


What is static constructor, when it will be fired? And what is its use?

719


Describe the compilation process for .net code?

815