public class OneTimeRunner
{
private volatile bool _runBefore;
public void Run(Action action)
{
if (_runBefore)
{
return;
}
lock (this)
{
if (_runBefore)
{
return;
}
action();
_runBefore = true;
}
}
}
C# 中只运行一次帮助类
最新推荐文章于 2023-07-10 09:56:25 发布