Exemplo n.º 1
0
        public static void Main(string[] args)
        {
            Console.WriteLine("begin Generate");

            TupleAction AtEvent1 =
                n =>
            {
                Console.WriteLine("event: " + n.Data1);
                Console.WriteLine("3");
                Thread.Sleep(500);
                Console.WriteLine("2");
                Thread.Sleep(500);
                Console.WriteLine("1");
                Thread.Sleep(500);
            };

            // this is our call site context..
            var AtEvent_Context = Marshal.AllocHGlobal(1);
            var t = new Thread(
                delegate()
            {
                ExtensionsToSwitchToCLRContext.Generate(AtEvent_Context);
                ExtensionsToSwitchToCLRContext.AtEvent1_EndAsync(AtEvent_Context);
            }
                );

            ExtensionsToSwitchToCLRContext.AtEvent1_BeginAsync(AtEvent_Context);

            t.Start();

            while (t.IsAlive)
            {
                var n = ExtensionsToSwitchToCLRContext.AtEvent1_Poll(AtEvent_Context);

                if (n != null)
                {
                    AtEvent1(n);
                }
                else
                {
                    Console.WriteLine("no event");
                }
            }

            Marshal.FreeHGlobal(AtEvent_Context);
            t.Join();

            Console.WriteLine("end Generate");
        }
Exemplo n.º 2
0
        public static void Generate(
            TupleAction AtEvent1
            )
        {
            StringAction Notify =
                text =>
            {
                Console.WriteLine(text);

                var a = new Tuple {
                    Data1 = text
                };

                if (AtEvent1 != null)
                {
                    AtEvent1(a);
                }
            };

            Notify("  beginning");

            for (int i = 0; i < 8; i++)
            {
                Thread.Sleep(500);
                Console.Write(".");
            }
            Console.WriteLine();

            Notify("  middle");

            for (int i = 0; i < 8; i++)
            {
                Thread.Sleep(500);
                Console.Write(".");
            }
            Console.WriteLine();

            Notify("  end");
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            Console.WriteLine("begin Generate");

            TupleAction AtEvent1 =
                n =>
            {
                Console.WriteLine("event: " + n.Data1);
                Console.WriteLine("3");
                Thread.Sleep(500);
                Console.WriteLine("2");
                Thread.Sleep(500);
                Console.WriteLine("1");
                Thread.Sleep(500);
            };

            ExtensionsToSwitchToCLRContext.Generate(
                AtEvent1
                );

            Console.WriteLine("end Generate");
        }
Exemplo n.º 4
0
        public static void Generate(
            TupleAction AtEvent1
        )
        {
            StringAction Notify =
                text =>
                {
                    Console.WriteLine(text);

                    var a = new Tuple { Data1 = text };

                    if (AtEvent1 != null)
                        AtEvent1(a);
                };

            Notify("  beginning");

            for (int i = 0; i < 8; i++)
            {
                Thread.Sleep(500);
                Console.Write(".");
            }
            Console.WriteLine();

            Notify("  middle");

            for (int i = 0; i < 8; i++)
            {
                Thread.Sleep(500);
                Console.Write(".");
            }
            Console.WriteLine();

            Notify("  end");

        }
Exemplo n.º 5
0
        public static void Generate(
#if FEATURE_DELEGATE
            TupleAction AtEvent1
Exemplo n.º 6
0
        public static void Generate(
#if FEATURE_DELEGATE
            TupleAction AtEvent1