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
Explain the difference between the stack and the heap?
hai, about trading domain and need simple project on trading system. please help me...
what is the default security setting in .net?
Difference between machine.config and web.config?
Explain how to stop a thread?
Explain what are possible implementations of distributed applications in .net?
How many design patterns can be created in .net?
If I am writing in a language like vb or c++, what are the procedures to be followed to support .net?
Is .net core managed code?
What's wrong with a line like this? Datetime.parse(mystring);
What are the collections you've used?
What is Event Bubbling in .NET?
How to implement CAS in .Net?
What is data type and how many types of data types are in .NET ?
What is the difference between reference type and value type?