コード例 #1
0
        //
        // Implementation of InvokeMultiple
        //

        internal static IInvokeAsyncResult BeginInvokeMultiple(VirtualMachine vm, ThreadMirror thread, MethodMirror[] methods, Value this_obj, IList <IList <Value> > arguments, InvokeOptions options, AsyncCallback callback, object state)
        {
            if (thread == null)
            {
                throw new ArgumentNullException("thread");
            }
            if (methods == null)
            {
                throw new ArgumentNullException("methods");
            }
            foreach (var m in methods)
            {
                if (m == null)
                {
                    throw new ArgumentNullException("method");
                }
            }
            if (arguments == null)
            {
                arguments = new List <IList <Value> > ();
                for (int i = 0; i < methods.Length; ++i)
                {
                    arguments.Add(new Value [0]);
                }
            }
            else
            {
                // FIXME: Not needed for property evaluation
                throw new NotImplementedException();
            }
            if (callback == null)
            {
                throw new ArgumentException("A callback argument is required for this method.", "callback");
            }

            InvokeFlags f = InvokeFlags.NONE;

            if ((options & InvokeOptions.DisableBreakpoints) != 0)
            {
                f |= InvokeFlags.DISABLE_BREAKPOINTS;
            }
            if ((options & InvokeOptions.SingleThreaded) != 0)
            {
                f |= InvokeFlags.SINGLE_THREADED;
            }

            InvokeAsyncResult r = new InvokeAsyncResult {
                AsyncState = state, AsyncWaitHandle = new ManualResetEvent(false), VM = vm, Thread = thread, Callback = callback, NumPending = methods.Length, IsMultiple = true
            };

            var mids = new long [methods.Length];

            for (int i = 0; i < methods.Length; ++i)
            {
                mids [i] = methods [i].Id;
            }
            var args = new List <ValueImpl[]> ();

            for (int i = 0; i < methods.Length; ++i)
            {
                args.Add(vm.EncodeValues(arguments [i]));
            }
            r.ID = vm.conn.VM_BeginInvokeMethods(thread.Id, mids, this_obj != null ? vm.EncodeValue(this_obj) : vm.EncodeValue(vm.CreateValue(null)), args, f, InvokeMultipleCB, r);

            return(r);
        }
コード例 #2
0
        internal static IInvokeAsyncResult BeginInvokeMethod(VirtualMachine vm, ThreadMirror thread, MethodMirror method, Value this_obj, IList <Value> arguments, InvokeOptions options, AsyncCallback callback, object state)
        {
            if (thread == null)
            {
                throw new ArgumentNullException("thread");
            }
            if (method == null)
            {
                throw new ArgumentNullException("method");
            }
            if (arguments == null)
            {
                arguments = new Value [0];
            }

            InvokeFlags f = InvokeFlags.NONE;

            if ((options & InvokeOptions.DisableBreakpoints) != 0)
            {
                f |= InvokeFlags.DISABLE_BREAKPOINTS;
            }
            if ((options & InvokeOptions.SingleThreaded) != 0)
            {
                f |= InvokeFlags.SINGLE_THREADED;
            }

            InvokeAsyncResult r = new InvokeAsyncResult {
                AsyncState = state, AsyncWaitHandle = new ManualResetEvent(false), VM = vm, Thread = thread, Callback = callback
            };

            r.ID = vm.conn.VM_BeginInvokeMethod(thread.Id, method.Id, this_obj != null ? vm.EncodeValue(this_obj) : vm.EncodeValue(vm.CreateValue(null)), vm.EncodeValues(arguments), f, InvokeCB, r);

            return(r);
        }