public class SplashScreen : Form { public Bitmap SImage {get; set;} Thread t; public void Flash() { PictureBox pb = new PictureBox(); pb.SizeMode = PictureBoxSizeMode.AutoSize; pb.Image = SImage; this.Width = pb.Width; this.Height = pb.Height; this.Controls.Add(pb); this.TopMost = true; this.StartPosition = FormStartPosition.CenterScreen; this.FormBorderStyle = FormBorderStyle.None; Application.Run(this); } public void sClose() { this.Close(); } public void ShowSplash() { t = new Thread(new ThreadStart(Flash)); t.IsBackground = true; t.SetApartmentState(ApartmentState.STA); t.Start(); } public void CloseSplash() { if (this.InvokeRequired) { this.Invoke(new MethodInvoker(sClose)); } } }
SplashScreen sc = new SplashScreen(); sc.SImage = (Bitmap)Image.FromFile("processing.gif"); sc.ShowSplash(); //... codes codes codes... sc.CloseSplash();
t
if(t!= null && t.IsAlive()) //To make shore that the thread is running! t.Abort();
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)