Elight.Utility/Threads/MyTask.cs
(完整代码) 1KBusing System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace Elight.Utility.Threads
{
public class MyTask
{
private bool close;
Thread thread;
public void Run(Action action)
{
thread = new Thread(() => action());
thread.Start();
}
public void RunWhileTrue(Action actionLoop)
{
RunWhileTrue(actionLoop, 200);
}
public void RunWhileTrue(Action actionLoop, int sleepTime)
{
thread = new Thread(() =>
{
while (!close)
{
try
{
actionLoop();
}
catch
{
}
Thread.Sleep(sleepTime);
}
});
thread.Start();
}
public void Close()
{
close = true;
try { thread.Abort(); } catch { }
}
}
}
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。