111,120
社区成员
发帖
与我相关
我的任务
分享
class progrom
{
delegate void DL();
event DL sj;
static void Main(string[] args)
{
progrom pp = new progrom();
pp.sj += new DL(Print);
pp.sj();
}
static void Print()
{
Console.WriteLine("P");
}
}
static void Main(string[] args)
{
MyThread myThread = new MyThread();
Thread th = new Thread(myThread.Start);
myThread.StopThread += delegate
{
th.Abort();
};
th.Start();
}
}
public class MyThread
{
public delegate void StopThreadHandler(object sender);
public StopThreadHandler StopThread;
public void Start()
{
ConsoleKeyInfo key;
while (true)
{
key = Console.ReadKey();
if (key.KeyChar == ' ')
if (StopThread != null)
StopThread(this);
}
}
}