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 are the features of dot net?
What are the new thee features of com+ services, which are not there in com (mts)?
Do you know what are three common acronyms used in .net, and what do they stand for?
What is alias ? Is it used in .Net ?
Who is using .net core?
What is a windows process in .net?
what is the meaning silverligt control
How will you register com+ services?
What is the benefit of .net core?
How do I spawn a thread?
Explain the difference between vb and vb.net?
Do you know what's the difference between .net and laravel?
What is the difference between "using system.data;" and directly adding the reference from "add references dialog box"?
State some of the different languages supported by .net?
Differentiate between managed and unmanaged code?