C# 2.0 에서는 ThreadStart delegate를 사용하지 않아도 된다.
아래 예제를 보자.
아래 예제는 앞 예제와 같은 것이다.
하지만 ThreadStart delegate를 사용하지 않았다.
아래 예제를 보자.
아래 예제는 앞 예제와 같은 것이다.
하지만 ThreadStart delegate를 사용하지 않았다.
using System;
using System.Threading;
namespace ThreadSample
{
class Program
{
public const int Repetitions = 1000;
static void Main(string[] args)
{
Thread myThread = new Thread(DoWork);
myThread.Start();
for (int count = 0; count < Repetitions; count++)
{
Console.Write('-');
}
myThread.Join();
}
public static void DoWork()
{
for (int count = 0; count < Repetitions; count++)
{
Console.Write('.');
}
}
}
}
using System.Threading;
namespace ThreadSample
{
class Program
{
public const int Repetitions = 1000;
static void Main(string[] args)
{
Thread myThread = new Thread(DoWork);
myThread.Start();
for (int count = 0; count < Repetitions; count++)
{
Console.Write('-');
}
myThread.Join();
}
public static void DoWork()
{
for (int count = 0; count < Repetitions; count++)
{
Console.Write('.');
}
}
}
}
'Code > C#' 카테고리의 다른 글
| Thread & Lock 사용법과 예제 (0) | 2007.12.08 |
|---|---|
| Thread & Monitor 사용 방법과 예제 (0) | 2007.12.08 |
| [C#] Thread 샘플 코드 4 (0) | 2007.12.08 |
| [C#] Thread & FileStream 사용 예제 (0) | 2007.12.07 |
| [C#] Thread 샘플 코드 3 (0) | 2007.12.07 |