1
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
#if NETCOREAPP
|
#if NETCOREAPP
|
||||||
using System;
|
using System;
|
||||||
|
using System.Timers;
|
||||||
using Cysharp.Threading.Tasks;
|
using Cysharp.Threading.Tasks;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
@@ -10,6 +11,10 @@ public class BITAppForNet
|
|||||||
[Obsolete("Use InitializeAsync instead")]
|
[Obsolete("Use InitializeAsync instead")]
|
||||||
public static UniTask Init(string name)=>UniTask.CompletedTask;
|
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)
|
public static async UniTask InitializeAsync(string name)
|
||||||
{
|
{
|
||||||
BIT4Log.OnLog += Console.WriteLine;
|
BIT4Log.OnLog += Console.WriteLine;
|
||||||
@@ -18,11 +23,26 @@ public class BITAppForNet
|
|||||||
BIT4Log.OnSetConsoleColor += color => Console.ForegroundColor = color;
|
BIT4Log.OnSetConsoleColor += color => Console.ForegroundColor = color;
|
||||||
BIT4Log.OnNextLine += Console.WriteLine;
|
BIT4Log.OnNextLine += Console.WriteLine;
|
||||||
|
|
||||||
|
|
||||||
|
_timer.Elapsed += OnTick;
|
||||||
|
_timer.Interval = 16;
|
||||||
|
_timer.Start();
|
||||||
|
|
||||||
await BITApp.Start(name);
|
await BITApp.Start(name);
|
||||||
await BITBinary.Start();
|
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()
|
public static UniTask DisposeAsync()
|
||||||
{
|
{
|
||||||
|
_timer.Stop();
|
||||||
|
_timer.Elapsed -= OnTick;
|
||||||
BITApp.Stop();
|
BITApp.Stop();
|
||||||
return UniTask.CompletedTask;
|
return UniTask.CompletedTask;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user