コード例 #1
0
 //and elf wants to meet with Santa
 public void elf(Elf e)
 {
     elf(e, default(CancellationToken), null, null);
 }
コード例 #2
0
        private IEnumerable <Expression> __concurrentelf(Elf e, CancellationToken __cancellation, Action <object> __success, Action <Exception> __failure)
        {
            if (_busy)
            {
                e.advice(false);
                {
                    __dispatch("elf");
                    if (__success != null)
                    {
                        __success(null);
                    }
                    yield break;
                }
            }

            _elves.Add(e);
            if (_elves.Count == 3)
            {
                _busy = true;
                Console.WriteLine("Santa: hey guys, need help?");
                var __expr7_var = new __expr7 {
                    Start = (___expr) =>
                    {
                        var __expr = (__expr7)___expr;
                        Task.Delay((int)((1) * 1000)).ContinueWith(__task =>
                        {
                            __enter(() => __expr.__op11(true, null, null), (__ex) => __expr.__op11(false, null, __ex));
                        }

                                                                   );
                        __listen("cancelMeeting", () =>
                        {
                            __expr.__op11(null, true, null);
                        }

                                 );
                    }

                    , End = (__expr) =>
                    {
                        __enter(() => __advance(__expr.Continuator), __failure);
                    }
                };
                yield return(__expr7_var);

                if (__expr7_var.Failure != null)
                {
                    throw __expr7_var.Failure;
                }
                var isDelivering = readyToDeliver();
                if (isDelivering) //therefore the meeting was canceled
                {
                    Console.WriteLine("Santa: sorry fellows, got toys to deliver!");
                    meetingCanceled();
                }
                else
                {
                    Console.WriteLine("Santa: Good meeting, little fellas!");
                    _busy = false;
                }

                //adjourned
                foreach (var elf in _elves)
                {
                    elf.advice(!isDelivering);
                }

                _elves.Clear();
            }

            {
                __dispatch("elf");
                if (__success != null)
                {
                    __success(null);
                }
                yield break;
            }
        }