예제 #1
0
        public static void Call()
        {
            SayHi del = EnglishSayHi;

            del("李四");
            Test("张三", chineseSayHi);
        }
예제 #2
0
        static void Main(string[] args)
        {
            WorkflowEngine workflowEngine = new WorkflowEngine();

            UpLoadVideo activity = new UpLoadVideo();

            SayHi sayHi = new SayHi();

            workflowEngine.Run(sayHi);

            //workflowEngine.Run(activity);

            Console.ReadLine();
        }
예제 #3
0
        delegate string SayHi(String name);//定义委托

        static void Main(string[] args)
        {
            SayHi sayhi = new SayHi(SayHiName); //实例化委托

            sayhi("科比");                        //一般的直接调用
            sayhi.Invoke("张林");                 //使用Invoke方法同步调用
            //异步调用
            sayhi.BeginInvoke("杜兰特", (IAsyncResult ar) =>
            {
                sayhi.EndInvoke(ar);
                Console.WriteLine("打招呼成功结束");
            }, null);
            Console.ReadLine();
        }
예제 #4
0
        private void Test2_Click(object sender, RoutedEventArgs e)
        {
            RandSelect randSelect = delegate()
            {
                // 定義一個SayHi變數s1, 利用匿名方法初始化之
                SayHi  s1  = delegate() { return("Hello world!"); };
                SayHi  s2  = delegate() { return("It's me, Ryan!"); };
                Random c   = new Random((int)DateTime.Now.Ticks);
                double x   = c.NextDouble();
                string str = x > 0.5 ? s1() : s2();
                return(string.Format("{0} \r\n {1}", x, str));
            };

            test2.Text = randSelect();
        }
예제 #5
0
        static void Main(string[] args)
        {
            IntroduceYourself("John");

            SayHi hey = new SayHi(IntroduceYourself);

            hey("Cathy");

            // Pass it down as an arg and use it in another function
            Greeting(hey);

            // Look, ma ... no Instantiation
            Greeting(IntroduceYourself);

            EvensAndOddsDemo();
        }
예제 #6
0
 static void Greeting(SayHi yo)
 {
     yo("Zach");
 }
예제 #7
0
 public static void Hello(string name, SayHi delegateSayHi)
 {
     delegateSayHi(name);
 }
예제 #8
0
 static void Test(string name, SayHi del)
 {
     del(name);
 }
예제 #9
0
        void HandleOnGetEventInfoCompleted(SayHi.API.Models.Event obj)
        {
            SayHiBootStrapper.SetCurrentEvent (obj);
            if (obj.IsSucess)
            {
                this.InvokeOnMainThread (
                    delegate
                {
                    PerformSegue (SayHiConstants.SHVCtoESVCSegue, this);
                });
            }
            else
            {
                this.InvokeOnMainThread (
                    delegate
                {
                    SayHiBootStrapper.ShowAlertMessage ("Error", "Could not retrieve event. Be sure that the code is correct and you are connected to a network");
                });
            }

            isWaiting = false;
        }