添加项目文件。

This commit is contained in:
Administrator
2026-08-04 18:36:40 +08:00
parent 16fb9e4f5a
commit a2ecbc795d
616 changed files with 149853 additions and 0 deletions
+36
View File
@@ -0,0 +1,36 @@
using System;
using System.Diagnostics;
using System.Threading;
namespace JinYuan.Helper
{
/// <summary>
/// 操作计时功能
/// </summary>
public class TimedOperation : IDisposable
{
private readonly Stopwatch _stopwatch;
private readonly string _operationName;
private readonly Action<long, string> _onCompleted;
private bool _disposed = false;
public TimedOperation(string operationName, Action<long, string> onCompleted = null)
{
_stopwatch = Stopwatch.StartNew();
_operationName = operationName;
_onCompleted = onCompleted;
}
public long ElapsedMilliseconds => _stopwatch.ElapsedMilliseconds;
public void Dispose()
{
if (!_disposed)
{
_stopwatch.Stop();
_onCompleted?.Invoke(_stopwatch.ElapsedMilliseconds, _operationName);
_disposed = true;
}
}
}
}