zoukankan      html  css  js  c++  java
  • C#匿名代理的使用

     private delegate void CrossThreadOperationControl();
    
    
               // 将代理实例化为一个匿名代理 
    
                CrossThreadOperationControl CrossDelete = delegate()
    
                {
    
                    MessageBoxButtons buttons = MessageBoxButtons.OKCancel;
    
                    DialogResult dr = MessageBox.Show("Master,please to have a rest!", "Interrupt", buttons);
    
                    if (dr == DialogResult.OK)
    
                    {
    
                        BlockInput(true);
    
                        SendMessage(this.Handle, WM_SYSCOMMAND, SC_MONITORPOWER, 2);
    
                        myTimere.Stop();
    
                        System.Threading.Thread.Sleep(mySpantime);
    
                        myTimere.Start();
    
                        BlockInput(false);
    
                    }
    
                    else
    
                    {
    
                        myWatch.Stop();
    
                        MessageBox.Show("Time setting be cancled!");
    
                        Application.Exit();
    
                    }
    
                };
    
                this.Invoke(CrossDelete);
    
    方法2
    
    
            this.Invoke(new MethodInvoker(delegate()
    
                    {
    
                    MessageBoxButtons buttons = MessageBoxButtons.OKCancel;
    
                    DialogResult dr = MessageBox.Show("Master,please to have a rest!", "Interrupt", buttons);
    
                    if (dr == DialogResult.OK)
    
                    {
    
                        BlockInput(true);
    
                        SendMessage(this.Handle, WM_SYSCOMMAND, SC_MONITORPOWER, 2);
    
                        myTimere.Stop();
    
                        System.Threading.Thread.Sleep(mySpantime);
    
                        myTimere.Start();
    
                        BlockInput(false);
    
                    }
    
                    else
    
                    {
    
                        myWatch.Stop();
    
                        MessageBox.Show("Time setting be cancled!");
    
                        Application.Exit();
    
                    }
    
                    }));
  • 相关阅读:
    codeforces 501 C,D,E
    bzoj 3172 单词 ac自动机|后缀数组
    HDU2459 后缀数组+RMQ
    POJ 3294 二分找超过一半字符串中存在的子串
    头文件
    python爬取文本
    python爬取图片
    NEW
    dsu on tree 练习题
    lzz分块+莫队
  • 原文地址:https://www.cnblogs.com/maijin/p/2826465.html
Copyright © 2011-2022 走看看