splasher.cs

来自「一个很简单的考试系统。实用性很强啊!数据库在里面」· CS 代码 · 共 72 行

CS
72
字号
using System;
using System.Threading;
using System.Windows.Forms;

namespace bizdb
{
	public class Splasher
	{
		static SplashForm MySplashForm = null;
		static Thread MySplashThread = null;

		//	internally used as a thread function - showing the form and
		//	starting the messageloop for it
		static void ShowThread() 
		{
			MySplashForm = new SplashForm();
			Application.Run(MySplashForm);
		}

		//	public Method to show the SplashForm
		static public void Show() 
		{
			if (MySplashThread != null)
				return;

			MySplashThread = new Thread(new ThreadStart(Splasher.ShowThread));
			MySplashThread.IsBackground = true;
			MySplashThread.ApartmentState = ApartmentState.STA;
			MySplashThread.Start();
		}

		//	public Method to hide the SplashForm
		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;
		}

		//	public Method to set or get the loading Status
		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;
			}
		}
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?