127.0.
智能大石头 authored at 2024-11-20 00:19:29
830.00 B
Stardust
using System.Threading;
using System.Threading.Tasks;
using Stardust.Data;

namespace StarGateway
{
    class InitService : IHostedService
    {
        public Task StartAsync(CancellationToken cancellationToken)
        {
            //await Task.Yield();

            Task.Run(() =>
            {
                // 配置
                var set = NewLife.Setting.Current;
                if (set.IsNew)
                {
                    set.DataPath = "../Data";
                    set.Save();
                }

                // 初始化数据库
                var n = App.Meta.Count;
                //AppStat.Meta.Session.Dal.Db.ShowSQL = false;
            });

            return Task.CompletedTask;
        }

        public Task StopAsync(CancellationToken cancellationToken) => Task.CompletedTask;
    }
}