using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; using System.Windows.Forms; namespace MyCommanHelper { public class ApplicationHelper { /// <summary> /// 线程只运行一次 /// </summary> /// <param name="frm">对话框程序</param> /// <param name="sProductName">产品名</param> /// <returns></returns> public static void RunOnlyOnce(Form frm, string sProductName) { bool createdNew = false; Mutex mutex = new Mutex(true, sProductName, out createdNew); if (createdNew) { Application.Run(frm); mutex.ReleaseMutex(); mutex.Close(); mutex.Dispose(); } else { MessageBoxHelper.ShowInfoMessage(sProductName + "已经启动!"); } } /// <summary> /// 设置漏斗光标 /// </summary> public static void SetWaitCursor() { Cursor.Current = Cursors.WaitCursor; } /// <summary> /// 设置光标为默认值 /// </summary> public static void ResetCursor() { Cursor.Current = Cursors.Default; } /// <summary> /// 处理当前在消息队列中的所有 Windows 消息。 /// </summary> public static void DoEvents() { Application.DoEvents(); } } }