示例#1
0
 public EventSink(RefDel _refmsg, RemoteObject _obj)
 {
     this.refmsg = _refmsg;
     obj         = _obj;
     потокЗаписи = new Thread(new ThreadStart(SaveFile));
     MessageBox.Show("sink constructed");
 }
示例#2
0
        static void Main(string[] args)
        {
            WuDel_Class wuDel_Class = new WuDel_Class();
            //调用无参数的委托
            WuDel wuDel = wuDel_Class.Print1;

            wuDel += wuDel_Class.Print2;
            wuDel += wuDel_Class.Print1;//现在,委托的方法列表中有3个方法
            Console.WriteLine("无参委托:");
            if (null != wuDel)
            {
                wuDel();
            }
            else
            {
                Console.WriteLine("委托为空");
            }

            IntDel_Class intDel_Class = new IntDel_Class();
            //调用有返回值的委托
            IntDel intDel = intDel_Class.Add2;

            intDel += intDel_Class.Add3;
            intDel += intDel_Class.Add2;
            Console.WriteLine("带返回值委托:");
            Console.WriteLine("Value:{0}", intDel());

            RefDel_Class refDel_Class = new RefDel_Class();
            //带引用参数的委托
            RefDel refDel = refDel_Class.Add2;

            refDel += refDel_Class.Add3;
            refDel += refDel_Class.Add2;
            int Intvalue = 5;

            refDel(ref Intvalue);//调用
            Console.WriteLine("带引用参数的委托:");
            Console.WriteLine("Value:{0}", Intvalue.ToString());
            Console.ReadKey();
        }