using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
namespace ConsoleApplication1
{
class AUTO
{
static EventWaitHandle ev = new AutoResetEvent(false);
static EventWaitHandle EW = new AutoResetEvent(false);
static volatile string tack="a";
static void Main()
{
new Thread(new ThreadStart(work)).Start();
for(int i=1;i<=5;i++)
{
ev.WaitOne();
tack=tack.PadRight(i, 'h');
EW.Set();
}
ev.WaitOne(); tack = null; EW.Set();
Console.ReadLine();
}
static void work()
{
while (true)
{
ev.Set();
EW.WaitOne();
if (tack == null) return;
Console.WriteLine(tack);
}
}
}
}
c# 多线程 创建跨进程的EventWaitHandle 源码
最新推荐文章于 2022-05-10 12:53:25 发布