www.pudn.com > Splash.zip > Splash.cs
using System;
using System.Threading;
using System.Windows.Forms;
namespace Splash
{
///
/// Splash µÄժҪ˵Ã÷¡£
///
public class Splash
{
static frmSplash MySplashForm = null;
static Thread MySplashThread = null;
static void ShowThread()
{
MySplashForm = new frmSplash();
Application.Run(MySplashForm);
}
static public void Show()
{
if (MySplashThread != null)
return;
MySplashThread = new Thread(new ThreadStart(Splash.ShowThread));
MySplashThread.IsBackground = true;
MySplashThread.ApartmentState = ApartmentState.STA;
MySplashThread.Start();
}
static public void Close()
{
if (MySplashThread == null) return;
if (MySplashForm == null) return;
try
{
MySplashForm.Invoke(new MethodInvoker(MySplashForm.Close));
}
catch (Exception)
{
}
MySplashThread = null;
MySplashForm = null;
}
static public string Status
{
set
{
if (MySplashForm == null)
{
return;
}
MySplashForm.StatusInfo = value;
}
get
{
if (MySplashForm == null)
{
throw new InvalidOperationException("Splash Form not on screen");
}
return MySplashForm.StatusInfo;
}
}
}
}