Files
KJD_WebService/TEMUKJD/InitForm.cs
T

69 lines
2.1 KiB
C#

using TemuKJD.KJDForms.BaseForms;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace TemuKJD
{
public partial class InitForm : LRBaseForm
{
public InitForm()
{
InitializeComponent();
Load += InitForm_Load;
}
private void InitForm_Load(object sender, EventArgs e)
{
Task.Run(() =>
{
while (!Work.Initialization.IsCheckFilesFinish || !Program.IsInit || this.progressBarX1.Value < 50)
{
Thread.Sleep(new Random().Next(10, 50));
Invoke(new Action(() =>
{
this.progressBarX1.Value = Work.Initialization.InitPercent++;
this.progressBarX1.Maximum = 50;
}));
if (this.progressBarX1.Value >= 50)
Thread.Sleep(300);
}
Invoke(new Action(() =>
{
try
{
if (!Work.Initialization.IsCheckFilesSuccesss)
{
BaseMsgForm.ShowError("文件初始化失败,请检查是否有程序占用并使用管理员权限运行本程序!");
Process.GetCurrentProcess().Kill();
}
this.Hide();
new MainForm().ShowDialog();
}
catch (Exception ex)
{
BaseMsgForm.ShowError(ex.Message);
Process.GetCurrentProcess().Kill();
}
}));
});
}
private void InitForm_FormClosed(object sender, FormClosedEventArgs e)
{
Process.GetCurrentProcess().Kill();
}
}
}