我有,我不能用我自己解決一些奇怪的問題......我一直在使用線程創建的啓動畫面(Form3〜閃屏),應用程序獲取到部分閃屏不能正常關閉
後不知何故thread.Abort();
(實際上殺死線程)啓動畫面停留在屏幕上,直到我移動上面的鼠標,或點擊它的地方,對其他形式(如Form1中)......我已經變成,因爲,這更混亂當我運行應用程序時,不會發生在VS中。在啓動畫面是正常關閉......,它只是發生在已編譯的.exe Program.cs的
namespace ICAMReports
{
static class Program
{
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}
SplashScreen.cs
namespace ICAMReports
{
public partial class SplashScreen : Form
{
public SplashScreen()
{
InitializeComponent();
}
private void timer1_Tick(object sender, EventArgs e)
{
progressBar1.Increment(1);
if (progressBar1.Value == 100)
{
timer1.Stop();
}
}
}
}
Form1.cs的
namespace ICAMReports
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
Thread th = new Thread(new ThreadStart(splashScreen));
th.Start();
Thread.Sleep(3000);
th.Abort();
}
public void splashScreen()
{
Application.Run(new SplashScreen());
}
//this where the rest of code is placed....
}
}
任何線索,爲什麼會發生這種情況或如何解決這個問題?
截圖:
我不知道你怎麼能有'thread.Abort',並在同一個問題 – Sayse
Thread.Abort的其實是th.Abort「正常關閉」();在Form1.cs – dovla091
據我瞭解; Thread.sleep代碼(3000); - >停止當前線程,th.Abort(); - >殺死線程(因此關閉SplashScreen窗體...)糾正我,如果我錯了... – dovla091