我有,我不能用我自己解决一些奇怪的问题......我一直在使用线程创建的启动画面(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