Example #1
0
        public ApplicationSprite()
        {
            //__Thread.InternalWorkerInvoke_4ebbe596_06000030(this);
            //this.__out_Method_6d788eff_06000003();

            // "X:\jsc.svn\examples\actionscript\async\AsyncWorkerTask\AsyncWorkerTask.sln"
            // X:\jsc.svn\examples\actionscript\async\AsyncWorkerTask\AsyncWorkerTask\ApplicationSprite.cs
            // X:\jsc.svn\examples\actionscript\FlashWorkerExperiment\FlashWorkerExperiment\ApplicationSprite.cs


            // https://forums.adobe.com/thread/1164500

            // this looks like chrome context capture
            #region worker
            if (!Worker.current.isPrimordial)
            {
                var sw = Stopwatch.StartNew();

                // iOS workers is still on the roadmap.  I don't have a release date, but I know it'll be an extended beta type of feature.
                // Most of the concurrency work was gated on the new AOT compiler work, which is still being actively worked on.
                // Lots of bug and performance fixes were added to AIR 15 and we're not stopping there.

                var xfromWorker = (MessageChannel)Worker.current.getSharedProperty("fromWorker");

                var FunctionToken_TypeFullName = (string)Worker.current.getSharedProperty("FunctionToken_TypeFullName");
                var FunctionToken_MethodName   = (string)Worker.current.getSharedProperty("FunctionToken_MethodName");
                var arg0 = (string)Worker.current.getSharedProperty("arg0");

                //               enter click
                //{ { data = message from worker { { FunctionToken_TypeFullName = TestThreadStart.TheOtherClass, FunctionToken_MethodName = Invoke_6d788eff_0600001c } }, ElapsedMilliseconds = 1713 } }


                IntPtr pp = __IntPtr.OfFunctionToken(null,
                                                     FunctionToken_TypeFullName,
                                                     FunctionToken_MethodName
                                                     );


                MethodInfo mm = new __MethodInfo {
                    _Method = pp
                };

                //    t.text = "after invoke " + new { TheOtherClass.SharedField, sw.ElapsedMilliseconds };

                //xfromWorker.send("message from worker " + new { FunctionToken_TypeFullName, FunctionToken_MethodName });

                //throw null;



                mm.Invoke(null, new object[] { arg0 });

                //               enter click
                //{ { ElapsedMilliseconds = 3103, data = message from worker { { ElapsedMilliseconds = 3057, SharedField = { { data = null, i = 65534, j = 3 } } } } } }
                // {{ ElapsedMilliseconds = 3399, data = message from worker {{ ElapsedMilliseconds = 3352, SharedField = {{ data = hello world, i = 65534, j = 3 }} }} }}

                xfromWorker.send("message from worker " + new { sw.ElapsedMilliseconds, TheOtherClass.SharedField });

                return;
            }
            #endregion

            // {{ os = Windows 7, version = WIN 15,0,0,189, length = 333983, Target = null, Method = { _Target = , _Method = IntPtr { StringToken = , FunctionToken = function Function() {}, ClassToken =  } } }}
            // start0 = new __ParameterizedThreadStart(null, __IntPtr.op_Explicit_4ebbe596_06001686(TheOtherClass.Invoke_6d788eff_0600000c));
            //      start0 = new __ParameterizedThreadStart(null, __IntPtr.OfFunctionToken_4ebbe596_06001687(TheOtherClass.Invoke_6d788eff_0600000c,"TestThreadStart.TheOtherClass","Invoke_6d788eff_0600000c"));
            ParameterizedThreadStart y = TheOtherClass.Invoke;

            // can we call the method
            //            0007 0200034c ScriptCoreLib::ScriptCoreLib.ActionScript.Extensions.ZipFileEntry + Cookie`1

            //Unhandled Exception: System.AggregateException: One or more errors occurred. --->System.InvalidOperationException: internal compiler error at method
            // assembly: X:\jsc.svn\examples\actionscript\Test\TestThreadStart\TestThreadStart\bin\Debug\ScriptCoreLib.dll at
            // type: ScriptCoreLib.ActionScript.BCLImplementation.System.__Single, ScriptCoreLib, Version=4.5.0.0, Culture=neutral, PublicKeyToken=null
            // method: CompareTo
            // Object reference not set to an instance of an object.
            //    at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
            //   at System.Collections.Generic.Dictionary`2.set_Item(TKey key, TValue value)
            //   at jsc.Script.CompilerBase.  .    (Type , MethodBase , LocalVariableInfo , CompilerBase )
            //   at jsc.Script.CompilerBase.<WriteVariableName>b__0(Type , MethodBase , LocalVariableInfo )

            //           Unhandled Exception: System.AggregateException: One or more errors occurred. --->System.InvalidOperationException: internal compiler error at method
            //assembly: X:\jsc.svn\examples\actionscript\Test\TestThreadStart\TestThreadStart\bin\Debug\ScriptCoreLib.dll at
            //type: ScriptCoreLib.ActionScript.BCLImplementation.System.__BitConverter, ScriptCoreLib, Version=4.5.0.0, Culture=neutral, PublicKeyToken=null
            //method: GetBytes
            //Object reference not set to an instance of an object.
            //   at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
            //  at System.Collections.Generic.Dictionary`2.set_Item(TKey key, TValue value)
            //  at jsc.Script.CompilerBase.  .    (Type , MethodBase , LocalVariableInfo , CompilerBase )


            //{{ os = Windows 7, version = WIN 15,0,0,189, length = 334356, Target = null, Method = { _Target = , _Method = IntPtr { StringToken = , FunctionToken = function Function() {}, ClassToken =  } }, z = Type { TypeDescription =
            // <type name="TestThreadStart::TheOtherClass" base="Class" isDynamic="true" isFinal="true" isStatic="true">
            //  <extendsClass type="Class"/>
            //  <extendsClass type="Object"/>
            //  <accessor name="prototype" access="readonly" type="*" declaredBy="Class"/>
            //  <method name="Invoke_6d788eff_0600000c" declaredBy="TestThreadStart::TheOtherClass" returnType="void">
            //    <parameter index="1" type="Object" optional="false"/>
            //  </method>
            //  <factory type="TestThreadStart::TheOtherClass">
            //    <extendsClass type="Object"/>
            //  </factory>
            //</type> } }}

            //          {{ os = Windows 7, version = WIN 15,0,0,189, length = 334570, Target = null, Method = { _Target = , _Method = IntPtr { StringToken = ,
            //FunctionToken = function Function() {}, ClassToken =  } }, FullName = TestThreadStart::TheOtherClass, z = Type { TypeDescription = <type name="TestThreadStart::TheOtherClass" base="Class" isDynamic="true" isFinal="true" isStatic="true">
            //  <extendsClass type="Class"/>
            //  <extendsClass type="Object"/>
            //  <accessor name="prototype" access="readonly" type="*" declaredBy="Class"/>
            //  <method name="Invoke_6d788eff_0600000c" declaredBy="TestThreadStart::TheOtherClass" returnType="void">
            //    <parameter index="1" type="Object" optional="false"/>
            //  </method>
            //  <factory type="TestThreadStart::TheOtherClass">
            //    <extendsClass type="Object"/>
            //  </factory>
            //</type> }, zz = Type { TypeDescription = <type name="TestThreadStart::TheOtherClass" base="Class" isDynamic="true" isFinal="true" isStatic="true">
            //  <extendsClass type="Class"/>
            //  <extendsClass type="Object"/>
            //  <accessor name="prototype" access="readonly" type="*" declaredBy="Class"/>
            //  <method name="Invoke_6d788eff_0600000c" declaredBy="TestThreadStart::TheOtherClass" returnType="void">
            //    <parameter index="1" type="Object" optional="false"/>
            //  </method>
            //  <factory type="TestThreadStart::TheOtherClass">
            //    <extendsClass type="Object"/>
            //  </factory>
            //</type> } }}

            //var z = typeof(TheOtherClass);
            //var zz = Type.GetType("TestThreadStart::TheOtherClass");
            //var zz = Type.GetType("TestThreadStart.TheOtherClass");

            //var zMethod = z.GetMethods();

            __MethodInfo p = y.Method;

            //{ { os = Windows 7, version = WIN 15,0,0,189, length = 335268,
            // FunctionToken_TypeFullName = TestThreadStart.TheOtherClass,
            // FunctionToken_MethodName = Invoke_6d788eff_0600000c
            // } }

            //var pt = Type.GetType(p._Method.FunctionToken_TypeFullName);



            //new ParameterizedThreadStart(null, pp);

            //new Delegate();



            var t = new TextField
            {
                multiline = true,
                //wordWrap = true,

                // {{ InternalPrimordialSprite = null, os = Windows 7, version = WIN 15,0,0,189, length = 353988, FunctionToken_TypeFullName = TestThreadStart.TheOtherClass, FunctionToken_MethodName = Invoke_6d788eff_06000016 }}

                text = new
                {
                    // did the compiler set it yet?
                    __Thread.InternalPrimordialSprite,

                    // http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/system/Capabilities.html
                    Capabilities.os,
                    Capabilities.version,

                    //WorkerDomain = WorkerDomain.isSupported,
                    //Worker = Worker.isSupported,
                    //Worker.current.isPrimordial,

                    this.loaderInfo.bytes.length,

                    // {{ os = Windows 7, version = WIN 15,0,0,189, length = 333411, Target = null, Method = { InternalFunctionPointer = function Function() {} } }}

                    //y.Target,

                    // first step is to call a static method on the other side of thread
                    //y.Method,
                    //y.Method,
                    //y.Method.DeclaringType


                    //z.FullName,

                    //z,

                    p._Method.FunctionToken_TypeFullName,
                    p._Method.FunctionToken_MethodName,
                }.ToString(),

                autoSize = TextFieldAutoSize.LEFT
            };

            t.AttachTo(this);

            t.click += delegate
            {
                var sw = Stopwatch.StartNew();

                t.text = "enter click";

                var w = WorkerDomain.current.createWorker(
                    this.loaderInfo.bytes
                    );

                //p._Method.FunctionToken_TypeFullName,
                //p._Method.FunctionToken_MethodName

                w.setSharedProperty("FunctionToken_TypeFullName", p._Method.FunctionToken_TypeFullName);
                w.setSharedProperty("FunctionToken_MethodName", p._Method.FunctionToken_MethodName);
                w.setSharedProperty("arg0", "hello world");

                var fromWorker = w.createMessageChannel(Worker.current);
                w.setSharedProperty("fromWorker", fromWorker);

                fromWorker.channelMessage +=
                    e =>
                {
                    var data = (string)fromWorker.receive();

                    t.appendText(

                        "\n " + new { sw.ElapsedMilliseconds, data }.ToString()

                        );
                };

                t.text = "enter click";
                w.start();


                //try
                //{
                //    // catch {{ err = ArgumentError: Error #1063: Argument count mismatch on TestThreadStart::TheOtherClass$/Invoke_6d788eff_06000013(). Expected 1, got 0. }}

                //    mm.Invoke(null, new object[1]);
                //    t.text = "after invoke " + new { TheOtherClass.SharedField, sw.ElapsedMilliseconds };
                //}
                //catch (Exception err)
                //{
                //    t.text = "catch " + new { err };
                //}
            };
        }
        public ApplicationSprite()
        {
            //__Thread.InternalWorkerInvoke_4ebbe596_06000030(this);
            //this.__out_Method_6d788eff_06000003();

            // "X:\jsc.svn\examples\actionscript\async\AsyncWorkerTask\AsyncWorkerTask.sln"
            // X:\jsc.svn\examples\actionscript\async\AsyncWorkerTask\AsyncWorkerTask\ApplicationSprite.cs
            // X:\jsc.svn\examples\actionscript\FlashWorkerExperiment\FlashWorkerExperiment\ApplicationSprite.cs


            // https://forums.adobe.com/thread/1164500

            // this looks like chrome context capture
            #region worker
            if (!Worker.current.isPrimordial)
            {
                var sw = Stopwatch.StartNew();

                // iOS workers is still on the roadmap.  I don't have a release date, but I know it'll be an extended beta type of feature.  
                // Most of the concurrency work was gated on the new AOT compiler work, which is still being actively worked on.  
                // Lots of bug and performance fixes were added to AIR 15 and we're not stopping there.

                var xfromWorker = (MessageChannel)Worker.current.getSharedProperty("fromWorker");

                var FunctionToken_TypeFullName = (string)Worker.current.getSharedProperty("FunctionToken_TypeFullName");
                var FunctionToken_MethodName = (string)Worker.current.getSharedProperty("FunctionToken_MethodName");
                var arg0 = (string)Worker.current.getSharedProperty("arg0");

                //               enter click
                //{ { data = message from worker { { FunctionToken_TypeFullName = TestThreadStart.TheOtherClass, FunctionToken_MethodName = Invoke_6d788eff_0600001c } }, ElapsedMilliseconds = 1713 } }


                IntPtr pp = __IntPtr.OfFunctionToken(null,
                    FunctionToken_TypeFullName,
                    FunctionToken_MethodName
                );


                MethodInfo mm = new __MethodInfo { _Method = pp };

                //    t.text = "after invoke " + new { TheOtherClass.SharedField, sw.ElapsedMilliseconds };

                //xfromWorker.send("message from worker " + new { FunctionToken_TypeFullName, FunctionToken_MethodName });

                //throw null;



                mm.Invoke(null, new object[] { arg0 });

                //               enter click
                //{ { ElapsedMilliseconds = 3103, data = message from worker { { ElapsedMilliseconds = 3057, SharedField = { { data = null, i = 65534, j = 3 } } } } } }
                // {{ ElapsedMilliseconds = 3399, data = message from worker {{ ElapsedMilliseconds = 3352, SharedField = {{ data = hello world, i = 65534, j = 3 }} }} }}

                xfromWorker.send("message from worker " + new { sw.ElapsedMilliseconds, TheOtherClass.SharedField });

                return;
            }
            #endregion

            // {{ os = Windows 7, version = WIN 15,0,0,189, length = 333983, Target = null, Method = { _Target = , _Method = IntPtr { StringToken = , FunctionToken = function Function() {}, ClassToken =  } } }}
            // start0 = new __ParameterizedThreadStart(null, __IntPtr.op_Explicit_4ebbe596_06001686(TheOtherClass.Invoke_6d788eff_0600000c));
            //      start0 = new __ParameterizedThreadStart(null, __IntPtr.OfFunctionToken_4ebbe596_06001687(TheOtherClass.Invoke_6d788eff_0600000c,"TestThreadStart.TheOtherClass","Invoke_6d788eff_0600000c"));
            ParameterizedThreadStart y = TheOtherClass.Invoke;

            // can we call the method
            //            0007 0200034c ScriptCoreLib::ScriptCoreLib.ActionScript.Extensions.ZipFileEntry + Cookie`1

            //Unhandled Exception: System.AggregateException: One or more errors occurred. --->System.InvalidOperationException: internal compiler error at method
            // assembly: X:\jsc.svn\examples\actionscript\Test\TestThreadStart\TestThreadStart\bin\Debug\ScriptCoreLib.dll at
            // type: ScriptCoreLib.ActionScript.BCLImplementation.System.__Single, ScriptCoreLib, Version=4.5.0.0, Culture=neutral, PublicKeyToken=null
            // method: CompareTo
            // Object reference not set to an instance of an object.
            //    at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
            //   at System.Collections.Generic.Dictionary`2.set_Item(TKey key, TValue value)
            //   at jsc.Script.CompilerBase.  .    (Type , MethodBase , LocalVariableInfo , CompilerBase )
            //   at jsc.Script.CompilerBase.<WriteVariableName>b__0(Type , MethodBase , LocalVariableInfo )

            //           Unhandled Exception: System.AggregateException: One or more errors occurred. --->System.InvalidOperationException: internal compiler error at method
            //assembly: X:\jsc.svn\examples\actionscript\Test\TestThreadStart\TestThreadStart\bin\Debug\ScriptCoreLib.dll at
            //type: ScriptCoreLib.ActionScript.BCLImplementation.System.__BitConverter, ScriptCoreLib, Version=4.5.0.0, Culture=neutral, PublicKeyToken=null
            //method: GetBytes
            //Object reference not set to an instance of an object.
            //   at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
            //  at System.Collections.Generic.Dictionary`2.set_Item(TKey key, TValue value)
            //  at jsc.Script.CompilerBase.  .    (Type , MethodBase , LocalVariableInfo , CompilerBase )


            //{{ os = Windows 7, version = WIN 15,0,0,189, length = 334356, Target = null, Method = { _Target = , _Method = IntPtr { StringToken = , FunctionToken = function Function() {}, ClassToken =  } }, z = Type { TypeDescription = 
            // <type name="TestThreadStart::TheOtherClass" base="Class" isDynamic="true" isFinal="true" isStatic="true">
            //  <extendsClass type="Class"/>
            //  <extendsClass type="Object"/>
            //  <accessor name="prototype" access="readonly" type="*" declaredBy="Class"/>
            //  <method name="Invoke_6d788eff_0600000c" declaredBy="TestThreadStart::TheOtherClass" returnType="void">
            //    <parameter index="1" type="Object" optional="false"/>
            //  </method>
            //  <factory type="TestThreadStart::TheOtherClass">
            //    <extendsClass type="Object"/>
            //  </factory>
            //</type> } }}

            //          {{ os = Windows 7, version = WIN 15,0,0,189, length = 334570, Target = null, Method = { _Target = , _Method = IntPtr { StringToken = , 
            //FunctionToken = function Function() {}, ClassToken =  } }, FullName = TestThreadStart::TheOtherClass, z = Type { TypeDescription = <type name="TestThreadStart::TheOtherClass" base="Class" isDynamic="true" isFinal="true" isStatic="true">
            //  <extendsClass type="Class"/>
            //  <extendsClass type="Object"/>
            //  <accessor name="prototype" access="readonly" type="*" declaredBy="Class"/>
            //  <method name="Invoke_6d788eff_0600000c" declaredBy="TestThreadStart::TheOtherClass" returnType="void">
            //    <parameter index="1" type="Object" optional="false"/>
            //  </method>
            //  <factory type="TestThreadStart::TheOtherClass">
            //    <extendsClass type="Object"/>
            //  </factory>
            //</type> }, zz = Type { TypeDescription = <type name="TestThreadStart::TheOtherClass" base="Class" isDynamic="true" isFinal="true" isStatic="true">
            //  <extendsClass type="Class"/>
            //  <extendsClass type="Object"/>
            //  <accessor name="prototype" access="readonly" type="*" declaredBy="Class"/>
            //  <method name="Invoke_6d788eff_0600000c" declaredBy="TestThreadStart::TheOtherClass" returnType="void">
            //    <parameter index="1" type="Object" optional="false"/>
            //  </method>
            //  <factory type="TestThreadStart::TheOtherClass">
            //    <extendsClass type="Object"/>
            //  </factory>
            //</type> } }}

            //var z = typeof(TheOtherClass);
            //var zz = Type.GetType("TestThreadStart::TheOtherClass");
            //var zz = Type.GetType("TestThreadStart.TheOtherClass");

            //var zMethod = z.GetMethods();

            __MethodInfo p = y.Method;

            //{ { os = Windows 7, version = WIN 15,0,0,189, length = 335268, 
            // FunctionToken_TypeFullName = TestThreadStart.TheOtherClass, 
            // FunctionToken_MethodName = Invoke_6d788eff_0600000c 
            // } }

            //var pt = Type.GetType(p._Method.FunctionToken_TypeFullName);




            //new ParameterizedThreadStart(null, pp);

            //new Delegate();




            var t = new TextField
            {
                multiline = true,
                //wordWrap = true,

                // {{ InternalPrimordialSprite = null, os = Windows 7, version = WIN 15,0,0,189, length = 353988, FunctionToken_TypeFullName = TestThreadStart.TheOtherClass, FunctionToken_MethodName = Invoke_6d788eff_06000016 }}

                text = new
                {
                    // did the compiler set it yet?
                    __Thread.InternalPrimordialSprite,

                    // http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/system/Capabilities.html
                    Capabilities.os,
                    Capabilities.version,

                    //WorkerDomain = WorkerDomain.isSupported,
                    //Worker = Worker.isSupported,
                    //Worker.current.isPrimordial,

                    this.loaderInfo.bytes.length,

                    // {{ os = Windows 7, version = WIN 15,0,0,189, length = 333411, Target = null, Method = { InternalFunctionPointer = function Function() {} } }}

                    //y.Target,

                    // first step is to call a static method on the other side of thread
                    //y.Method,
                    //y.Method,
                    //y.Method.DeclaringType


                    //z.FullName,

                    //z,

                    p._Method.FunctionToken_TypeFullName,
                    p._Method.FunctionToken_MethodName,

                }.ToString(),

                autoSize = TextFieldAutoSize.LEFT
            };

            t.AttachTo(this);

            t.click += delegate
            {
                var sw = Stopwatch.StartNew();

                t.text = "enter click";

                var w = WorkerDomain.current.createWorker(
                     this.loaderInfo.bytes
                 );

                //p._Method.FunctionToken_TypeFullName,
                //p._Method.FunctionToken_MethodName

                w.setSharedProperty("FunctionToken_TypeFullName", p._Method.FunctionToken_TypeFullName);
                w.setSharedProperty("FunctionToken_MethodName", p._Method.FunctionToken_MethodName);
                w.setSharedProperty("arg0", "hello world");

                var fromWorker = w.createMessageChannel(Worker.current);
                w.setSharedProperty("fromWorker", fromWorker);

                fromWorker.channelMessage +=
                        e =>
                        {
                            var data = (string)fromWorker.receive();

                            t.appendText(

                                "\n " + new { sw.ElapsedMilliseconds, data }.ToString()

                                );

                        };

                t.text = "enter click";
                w.start();


                //try
                //{
                //    // catch {{ err = ArgumentError: Error #1063: Argument count mismatch on TestThreadStart::TheOtherClass$/Invoke_6d788eff_06000013(). Expected 1, got 0. }}

                //    mm.Invoke(null, new object[1]);
                //    t.text = "after invoke " + new { TheOtherClass.SharedField, sw.ElapsedMilliseconds };
                //}
                //catch (Exception err)
                //{
                //    t.text = "catch " + new { err };
                //}


            };
        }
Example #3
0
        public static bool InternalWorkerInvoke(Sprite that)
        {
            var magic = (string)Worker.current.getSharedProperty("InternalWorkerInvoke");

            if (magic != "Run(Func<Task<TResult>>)")
            {
                return(false);
            }

            #region xfromWorkerConsole
            // X:\jsc.svn\examples\actionscript\Test\TestWorkerConsole\TestWorkerConsole\ApplicationSprite.cs
            var xfromWorkerConsole = (MessageChannel)Worker.current.getSharedProperty("fromWorkerConsole");

            var w = new __Console.__OutWriter
            {
                AtWriteLine = z =>
                {
                    xfromWorkerConsole.send(z);
                }
            };

            Console.SetOut(w);
            #endregion


            var FunctionToken_TypeFullName = (string)Worker.current.getSharedProperty("FunctionToken_TypeFullName");
            var FunctionToken_MethodName   = (string)Worker.current.getSharedProperty("FunctionToken_MethodName");

            IntPtr pp = __IntPtr.OfFunctionToken(null,
                                                 FunctionToken_TypeFullName,
                                                 FunctionToken_MethodName
                                                 );


            MethodInfo mm = new __MethodInfo {
                _Method = pp
            };

            //    t.text = "after invoke " + new { TheOtherClass.SharedField, sw.ElapsedMilliseconds };

            //xfromWorker.send("message from worker " + new { FunctionToken_TypeFullName, FunctionToken_MethodName });

            //throw null;



            // we are on a worker thread.
            // are we able to await and then respond and terminate?
            var value = (Task <object>)mm.Invoke(null, new object[] { });

            value.ContinueWith(
                task =>
            {
                // is the return type transerable?
                // or would we have to serialize it?

                var xfromWorker = (MessageChannel)Worker.current.getSharedProperty("fromWorker");
                // or are we to capture all fields modified within worker and only update those?
                xfromWorker.send(task.Result);
            }
                );



            return(true);
        }
Example #4
0
        public static bool InternalWorkerInvoke(Sprite that)
        {
            // pop ?

            if (Worker.current.isPrimordial)
            {
                InternalPrimordialSprite = that;
                return(false);
            }

            // X:\jsc.svn\examples\actionscript\Test\TestWorkerThrow\TestWorkerThrow\ApplicationSprite.cs
            InternalWorkerSprite = that;

            if (__Task.InternalWorkerInvoke(that))
            {
                // X:\jsc.svn\examples\actionscript\async\Test\TestAsyncTaskRun\TestAsyncTaskRun\ApplicationSprite.cs
                // Task.Run called itself

                return(true);
            }


            #region xfromWorkerConsole
            // X:\jsc.svn\examples\actionscript\Test\TestWorkerConsole\TestWorkerConsole\ApplicationSprite.cs
            var xfromWorkerConsole = (MessageChannel)Worker.current.getSharedProperty("fromWorkerConsole");

            var w = new __Console.__OutWriter
            {
                AtWriteLine = z =>
                {
                    xfromWorkerConsole.send(z);
                }
            };

            Console.SetOut(w);
            #endregion



            // X:\jsc.svn\examples\actionscript\Test\TestThreadStart\TestThreadStart\ApplicationSprite.cs

            // are we inside worker?

            var FunctionToken_TypeFullName = (string)Worker.current.getSharedProperty("FunctionToken_TypeFullName");
            var FunctionToken_MethodName   = (string)Worker.current.getSharedProperty("FunctionToken_MethodName");
            var arg0 = (string)Worker.current.getSharedProperty("arg0");

            IntPtr pp = __IntPtr.OfFunctionToken(null,
                                                 FunctionToken_TypeFullName,
                                                 FunctionToken_MethodName
                                                 );


            MethodInfo mm = new __MethodInfo {
                _Method = pp
            };

            //    t.text = "after invoke " + new { TheOtherClass.SharedField, sw.ElapsedMilliseconds };

            //xfromWorker.send("message from worker " + new { FunctionToken_TypeFullName, FunctionToken_MethodName });

            //throw null;


            try
            {
                mm.Invoke(null, new object[] { arg0 });
            }
            catch (Exception err)
            {
                // lets report anything back to the app
                // for now the best we can do is to print it to console in worker
                // and hope the app is showing the console in textfield

                //__Thread.InternalWorkerSprite.loaderInfo.uncaughtErrorEvents.uncaughtError +=
                // does not seem to work yet?

                Console.WriteLine("catch " + new { err });
                // X:\jsc.svn\examples\actionscript\Test\TestWorkerThrow\TestWorkerThrow\ApplicationSprite.cs
            }


            return(true);
        }
Example #5
0
        public static bool InternalWorkerInvoke(Sprite that)
        {
            // pop ?

            if (Worker.current.isPrimordial)
            {
                InternalPrimordialSprite = that;
                return false;
            }

            // X:\jsc.svn\examples\actionscript\Test\TestWorkerThrow\TestWorkerThrow\ApplicationSprite.cs
            InternalWorkerSprite = that;

            if (__Task.InternalWorkerInvoke(that))
            {
                // X:\jsc.svn\examples\actionscript\async\Test\TestAsyncTaskRun\TestAsyncTaskRun\ApplicationSprite.cs
                // Task.Run called itself

                return true;
            }


            #region xfromWorkerConsole
            // X:\jsc.svn\examples\actionscript\Test\TestWorkerConsole\TestWorkerConsole\ApplicationSprite.cs
            var xfromWorkerConsole = (MessageChannel)Worker.current.getSharedProperty("fromWorkerConsole");

            var w = new __Console.__OutWriter
            {
                AtWriteLine = z =>
                {
                    xfromWorkerConsole.send(z);
                }
            };

            Console.SetOut(w);
            #endregion



            // X:\jsc.svn\examples\actionscript\Test\TestThreadStart\TestThreadStart\ApplicationSprite.cs

            // are we inside worker?

            var FunctionToken_TypeFullName = (string)Worker.current.getSharedProperty("FunctionToken_TypeFullName");
            var FunctionToken_MethodName = (string)Worker.current.getSharedProperty("FunctionToken_MethodName");
            var arg0 = (string)Worker.current.getSharedProperty("arg0");

            IntPtr pp = __IntPtr.OfFunctionToken(null,
                 FunctionToken_TypeFullName,
                 FunctionToken_MethodName
             );


            MethodInfo mm = new __MethodInfo { _Method = pp };

            //    t.text = "after invoke " + new { TheOtherClass.SharedField, sw.ElapsedMilliseconds };

            //xfromWorker.send("message from worker " + new { FunctionToken_TypeFullName, FunctionToken_MethodName });

            //throw null;


            try
            {

                mm.Invoke(null, new object[] { arg0 });

            }
            catch (Exception err)
            {
                // lets report anything back to the app
                // for now the best we can do is to print it to console in worker
                // and hope the app is showing the console in textfield

                //__Thread.InternalWorkerSprite.loaderInfo.uncaughtErrorEvents.uncaughtError +=
                // does not seem to work yet?

                Console.WriteLine("catch " + new { err });
                // X:\jsc.svn\examples\actionscript\Test\TestWorkerThrow\TestWorkerThrow\ApplicationSprite.cs
            }


            return true;
        }