This commit is contained in:
parent
058759c815
commit
3d2d33a4bf
|
@ -1,5 +1,6 @@
|
|||
#if NETCOREAPP
|
||||
using System;
|
||||
using System.Timers;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
@ -9,6 +10,10 @@ public class BITAppForNet
|
|||
{
|
||||
[Obsolete("Use InitializeAsync instead")]
|
||||
public static UniTask Init(string name)=>UniTask.CompletedTask;
|
||||
|
||||
private static Timer _timer = new();
|
||||
|
||||
private static DateTime _startTime = DateTime.UtcNow;
|
||||
|
||||
public static async UniTask InitializeAsync(string name)
|
||||
{
|
||||
|
@ -17,12 +22,27 @@ public class BITAppForNet
|
|||
BIT4Log.OnException += e => Console.WriteLine(e.ToString());
|
||||
BIT4Log.OnSetConsoleColor += color => Console.ForegroundColor = color;
|
||||
BIT4Log.OnNextLine += Console.WriteLine;
|
||||
|
||||
|
||||
_timer.Elapsed += OnTick;
|
||||
_timer.Interval = 16;
|
||||
_timer.Start();
|
||||
|
||||
await BITApp.Start(name);
|
||||
await BITBinary.Start();
|
||||
}
|
||||
|
||||
private static void OnTick(object sender, ElapsedEventArgs e)
|
||||
{
|
||||
var time = (DateTime.UtcNow - _startTime).TotalSeconds;
|
||||
BITApp.Time.TimeAsDouble = time;
|
||||
BITApp.Time.ElapsedTime = (float) time;
|
||||
}
|
||||
|
||||
public static UniTask DisposeAsync()
|
||||
{
|
||||
_timer.Stop();
|
||||
_timer.Elapsed -= OnTick;
|
||||
BITApp.Stop();
|
||||
return UniTask.CompletedTask;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue