public System.Threading.Thread FactorialThread;
private void PreLoad_Load(object sender, System.EventArgs e)
{
blState = false; FactorialThread = new System.Threading.Thread(new
System.Threading.ThreadStart(this.LoadData));
// Starts the thread.
FactorialThread.Start();
timer1.Start();
} private void LoadData()
{
//读取数据库数据代码
ComLib.MemoryData.Init_dt_sss010607();
ComLib.MemoryData.Init_dt_sss010601_a();
ComLib.MemoryData.Init_dt_sss010601_b();
ComLib.MemoryData.Init_dt_sss010602_a();
ComLib.MemoryData.Init_dt_sss010602_b();
ComLib.MemoryData.Init_dt_sss010603_a();
ComLib.MemoryData.Init_dt_sss010603_b();
ComLib.MemoryData.Init_dt_sss010605();
ComLib.MemoryData.Init_dt_sss010606(); blState = true;
}
private void timer1_Tick(object sender, System.EventArgs e)
{
if(blState == true)
{
OpenWin();
}
}
private void OpenWin()
{
try
{
timer1.Stop(); FactorialThread.Abort(); FactorialThread.Join(); blState = false; main f = new main();// 打开主窗口 this.Hide(); f.Show(); GC.Collect(); this.Close();
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
我用这个程序来加载程序数据,为了显示一个窗口让用户等待,只好开了一个线程在后台读取数据,读取完成后加载主程序,结果运行一切正常,只是有一个很郁闷的问题,线程我已经关闭了,但是在主程序退出的时候,主程序的exe进程无法关闭,如果不开进程的话,就可以关闭,也就是用户在关闭main.exe的时候,任务管理器里面还有一个main.exe进程,无法关闭,不知道是什么问题,请高手指教,谢谢!