我有一个试图在 OnStop 方法中停止的线程,有人可以演示如何使用它终止/停止线程吗:
/// <summary>
/// OnStop: Put your stop code here
/// - Stop threads, set final data, etc.
/// </summary>
protected override void OnStop()
{
base.OnStop();
}
考虑到,即开始如下:
/// <summary>
/// OnStart: Put startup code here
/// - Start threads, get inital data, etc.
/// </summary>
/// <param name="args"></param>
protected override void OnStart(string[] args)
{
Thread MyThread = new Thread(new ThreadStart(MyThreadStarter));
MyThread.Start();
base.OnStart(args);
}
private void MyThreadStarter()
{
realtime obj = new realtime();
obj.Starter();
}
最佳答案
关于c# - 如何使用 OnStop 方法终止线程 (C#),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6456477/