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 .net applications?
How viewstate is being formed and how it's stored on client in .net?
hai, about trading domain and need simple project on trading system. please help me...
Please explain what is the difference between a class and an object?
Can I write my own .net host?
Please explain what are an object and a class?
Explain the difference between task and thread in .net?
How many namespaces are in .net version 1.1?
How anonymous method is different from a lambda expression?
What is the lapsed listener problem?
Please explain what is heap and what is stack?
What is an anonymous method?
What is STA in .NET?
What's a windows process in .net?
Explain the difference between public and static modifiers?