예제 #1
0
        public static bool ShowWarning(string msg)
        {
            frmWarning frm = new frmWarning();

            frm.RtbMsg.Text = msg;
            frm.ShowDialog();
            return(frm.DialogResult == DialogResult.OK);
        }
예제 #2
0
        /// <summary>
        /// 开始执行后台任务。
        /// </summary>
        /// <param name="param">处理参数。</param>
        /// <param name="processHandler">处理过程委托。</param>
        /// <param name="complateHandler">完成后执行委托。</param>
        /// <param name="infoMsg">提示信息,如果纯后台执行则传null即可。</param>
        public static void Start(object param, Func <object, object> processHandler, Action <object> complateHandler = null, string infoMsg = "处理中...")
        {
            TaskBase   taskBase = new TaskBase();
            frmWarning frmMsg   = null;

            if (!string.IsNullOrEmpty(infoMsg))
            {
                taskBase.BeforeProcessAction = delegate
                {
                    frmMsg = new frmWarning(infoMsg);
                    frmMsg.ShowDialog();
                };

                taskBase.AfterProcessAction = delegate
                {
                    if (frmMsg != null)
                    {
                        frmMsg.Dispose();
                    }
                };
            }
            taskBase.Start(param, processHandler, complateHandler);
        }