Esempio n. 1
0
        private static void CallBackCloseAlertForm(IAsyncResult ar)
        {
            //从C#异步调用状态ar.AsyncState中,获取委托对象
            CloseAlertFormdelegate dn = (CloseAlertFormdelegate)ar.AsyncState;

            //一定要EndInvoke,否则你的下场很惨
            dn.EndInvoke(ar);
        }
Esempio n. 2
0
 /// <summary>
 /// 关闭AlertForm
 /// </summary>
 /// <param name="frm"></param>
 public static void CloseAllAlertForm(Form frm)
 {
     if (frm.InvokeRequired)
     {
         CloseAlertFormdelegate outdelegate = new CloseAlertFormdelegate(CloseAllAlertForm);
         AsyncCallback          acb         = new AsyncCallback(CallBackCloseAlertForm);
         IAsyncResult           iar         = outdelegate.BeginInvoke(frm, acb, outdelegate);
     }
     else
     {
         frm.Close();
     }
 }