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
What is the use of Treeview control?
What is operator overloading in .net?
What are the different types of Classes in .NET?
What are the types of jit?
What is .net and .net framework?
What are the features of dot net?
Explain the difference between garbage collections in .net 4.0 and earlier versions?
What are the new 2.0 features useful for?
Explain is the jit an interpreter?
What is singleton activation mode in .net?
Please explain what are an inheritance, polymorphism, and encapsulation?
What are the differences between an interface and an abstract class in .net?
How to manage pagination in a page using .net?
What is static constructor, when it will be fired? And what is its use?
Describe the compilation process for .net code?