Пример #1
0
        public void cIfaceUnreg2()
        {
            IComparable comparable = testInstance.createJWithClrInterfaceUnreg(1);
            Runnable    cw1        = Bridge.Cast <Runnable>(comparable);

            cw1.run();
            cw1.run();
            cw1.run();
            var cw2 = testInstance.createJWithClrInterfaceUnreg(4);

            Assert.AreEqual(0, cw2.CompareTo(cw1));

            cw1.run();
            Assert.AreEqual((String)"5", cw1.ToString());
        }
Пример #2
0
    public static int test()
    {
        Runnable r = () => method();

        r.run();
        return(field);
    }
Пример #3
0
        //整体编译
        public int run(string path)
        {
            hasChild      = false;
            GSKDATA.SHIFT = false;
            ClearData();
            string text = File.ReadAllText(basepath + path);

            lexer   = new GSKLexer(text);
            program = new GSKParser(lexer, pointTable, orderPara, orderList, varBool, varR).parse();
            program.run();
            Debug.Log("总共的行数:" + orderList.Count);
            for (int i = 0; i < orderList.Count; i++)
            {
                if (orderList[i].type() == TokenType.MOVC)
                {
                    movc_num++;
                }
                else
                {
                    if (movc_num > 0 && movc_num < 3)
                    {
                        Debug.LogError("应该至少有三条圆弧指令!当前只有" + movc_num + "次");
                        return(-1);
                    }
                    else
                    {
                        movc_num = 0;
                    }
                }
            }
            return(0);
        }
Пример #4
0
 public virtual void run()
 {
     if (target != null)
     {
         target.run();
     }
 }
Пример #5
0
        /// <summary>
        /// Call the Engagement Service API if bound, otherwise keep the call for later use. </summary>
        /// <param name="cmd"> the task using the Engagement Service API. </param>
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
//ORIGINAL LINE: private void sendEngagementCommand(final Runnable cmd)
        private void sendEngagementCommand(Runnable cmd)
        {
            /* The command needs to run on the main thread to avoid race conditions */
            runOnMainThread(() =>
            {
                /* Nothing to do if disabled */
                if (!Enabled)
                {
                    return;
                }

                /* Bind if needed */
                bind();

                /* If we are not bound, spool command */
                if (mEngagementService == null)
                {
                    mPendingCmds.AddLast(cmd);
                    if (mPendingCmds.Count > MAX_COMMANDS)
                    {
                        mPendingCmds.RemoveFirst();
                    }
                }

                /* Otherwise call API and set unbind timer */
                else
                {
                    cmd.run();
                    scheduleUnbind();
                }
            });
        }
Пример #6
0
        public void cIfaceUnreg3()
        {
            Runnable runnable = testInstance.createJWithClrInterfaceUnregRun(1);

            runnable.run();
            runnable.run();
            runnable.run();
            var cw2 = testInstance.createJWithClrInterfaceUnreg(4);

            IComparable comparable = Bridge.Cast <IComparable>(runnable);

            Assert.AreEqual(0, comparable.CompareTo(cw2));

            runnable.run();
            Assert.AreEqual((String)"5", runnable.ToString());
        }
Пример #7
0
        public void run()
        {
            while (!IsAlive())
            { // isInterrupted()方法继承自Thread类,判断线程是否被中断
                Runnable task = null;
                try
                {
                    // 得到任务
                    task = getTask();
                }
                catch (InterruptedException ex)
                {
                }

                // 如果getTask()返回null或者线程执行getTask()时被中断,则结束此线程
                if (task == null)
                    return;

                try
                {
                    // 运行任务,捕获异常
                    task.run();
                }
                catch (Throwable t)
                {
                    t.printStackTrace();
                }
            }
        }
Пример #8
0
        public static void runAsAdmin(Runnable r)
        {
            System.Security.Principal.WindowsIdentity identity =
                System.Security.Principal.WindowsIdentity.GetCurrent();
            System.Security.Principal.WindowsPrincipal principal =
                new System.Security.Principal.WindowsPrincipal(identity);
            if (principal.IsInRole(System.Security.Principal.WindowsBuiltInRole.Administrator))
            {
                r.run();
            }
            else
            {
                //创建启动对象
                System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
                startInfo.UseShellExecute  = true;
                startInfo.WorkingDirectory = Environment.CurrentDirectory;
                startInfo.FileName         = Application.ExecutablePath;
                //startInfo.Arguments = String.Join(" ", "Args");
                //设置启动动作,确保以管理员身份运行
                startInfo.Verb = "runas";
                try
                {
                    System.Diagnostics.Process.Start(startInfo);
                }
                catch
                {
                    return;
                }

                //退出
                Application.Exit();
            }
        }
Пример #9
0
 public static Exception tryCatch(Runnable runnable) {
   try {
     runnable.run();
     return null;
   } catch (Exception exception) {
     return exception;
   }
 }
 public static Exception tryCatch(Runnable runnable)
 {
     try {
         runnable.run();
         return(null);
     } catch (Exception exception) {
         return(exception);
     }
 }
Пример #11
0
 /// <summary>
 /// Check calling thread, if main, run now, otherwise post in main thread </summary>
 private void runOnMainThread(Runnable task)
 {
     if (Thread.CurrentThread == mHandler.Looper.Thread)
     {
         task.run();
     }
     else
     {
         mHandler.post(task);
     }
 }
Пример #12
0
        public void Interfaces1()
        {
            CWithJavaInterface a   = new CWithJavaInterface(4);
            Runnable           cw  = testInstance.getCWithJavaInterface(a);
            CWithJavaInterface cwi = testInstance.getCWithJavaInterfaceC(a);

            cwi.run();
            cw.run();
            CWithJavaInterface tt = cw as CWithJavaInterface;

            Assert.AreEqual(6, tt.Value);
        }
Пример #13
0
        public AsyncFuture submit(Runnable r)
        {
            Task <object> task = Task.Factory.StartNew <object>(() =>
            {
                r.run();
                return(null);
            });

            lock (asyncTasks)
            {
                asyncTasks.Add(task);
            }
            return(new MonoGameAsyncFuture(task));
        }
Пример #14
0
        public virtual void statusChanged(Recognizer.State status)
        {
            List list = null;

            if (status == Recognizer.State.__ALLOCATED)
            {
                list = this.allocatedMonitors;
            }
            else if (status == Recognizer.State.__DEALLOCATED)
            {
                list = this.deallocatedMonitors;
            }
            if (list != null)
            {
                Iterator iterator = list.iterator();
                while (iterator.hasNext())
                {
                    Runnable runnable = (Runnable)iterator.next();
                    runnable.run();
                }
            }
        }
 private static void run(Runnable r) {
     r.run();
 }
Пример #16
0
 private static void run(Runnable r)
 {
     r.run();
 }
Пример #17
0
    public virtual void runBeforesThenTestThenAfters(Runnable test)
    {
      // ISSUE: fault handler
      try
      {
        try
        {
          this.runBefores();
          test.run();
          goto label_7;
        }
        catch (FailedBefore ex)
        {
        }
      }
      catch (Exception ex)
      {
        int num = 2;
        if (ByteCodeHelper.MapException<Exception>(ex, (ByteCodeHelper.MapFlags) num) == null)
          throw;
        else
          goto label_6;
      }
      __fault
      {
        this.runAfters();
      }
      this.runAfters();
      return;
label_6:
      // ISSUE: fault handler
      try
      {
        string str = "test should never throw an exception to this level";
        Throwable.__\u003CsuppressFillInStackTrace\u003E();
        throw new RuntimeException(str);
      }
      __fault
      {
        this.runAfters();
      }
label_7:
      this.runAfters();
    }
Пример #18
0
        public override void RunPendingAnimations()
        {
            bool removalsPending  = !mPendingRemovals.isEmpty();
            bool movesPending     = !mPendingMoves.isEmpty();
            bool additionsPending = !mPendingAdditions.isEmpty();

            if (!removalsPending && !movesPending && !additionsPending)
            {
                // nothing to animate
                return;
            }
            // First, remove stuff
            foreach (RecyclerView.ViewHolder holder in mPendingRemovals)
            {
                animateRemoveImpl(holder);
            }
            mPendingRemovals.clear();
            // Next, move stuff
            if (movesPending)
            {
                mMoves.addAll(mPendingMoves);
                mPendingMoves.clear();
                Runnable mover = new Runnable();
//				mover. {
//					@Override
//					public void run() {
//						for (MoveInfo moveInfo : mMoves) {
//							animateMoveImpl(moveInfo.holder, moveInfo.fromX, moveInfo.fromY,
//								moveInfo.toX, moveInfo.toY);
//						}
//						mMoves.clear();
//					}
//				};
                if (removalsPending)
                {
                    View view = mMoves.get(0).holder.itemView;
                    ViewCompat.postOnAnimationDelayed(view, mover, getRemoveDuration());
                }
                else
                {
                    mover.run();
                }
            }
            // Next, add stuff
            if (additionsPending)
            {
                mAdditions.addAll(mPendingAdditions);
                mPendingAdditions.clear();
                Runnable adder = new Runnable();
//				{
//					public void run() {
//						for (RecyclerView.ViewHolder holder : mAdditions) {
//							animateAddImpl(holder);
//						}
//						mAdditions.clear();
//					}
//				};
                if (removalsPending || movesPending)
                {
                    View view = mAdditions.get(0).itemView;
                    ViewCompat.postOnAnimationDelayed(view, adder,
                                                      (removalsPending ? getRemoveDuration() : 0) +
                                                      (movesPending ? getMoveDuration() : 0));
                }
                else
                {
                    adder.run();
                }
            }
        }
Пример #19
0
 public void run()
 {
     compoundStatment.run();
 }
Пример #20
0
        public override void runPendingAnimations()
        {
            bool removalsPending  = mPendingRemovals.Count > 0;
            bool movesPending     = mPendingMoves.Count > 0;
            bool changesPending   = mPendingChanges.Count > 0;
            bool additionsPending = mPendingAdditions.Count > 0;

            if (!removalsPending && !movesPending && !additionsPending && !changesPending)
            {
                // nothing to animate
                return;
            }
            // First, remove stuff
            foreach (RecyclerView.ViewHolder holder in mPendingRemovals)
            {
                animateRemoveImpl(holder);
            }
            mPendingRemovals.Clear();
            // Next, move stuff
            if (movesPending)
            {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.ArrayList<MoveInfo> moves = new java.util.ArrayList<MoveInfo>();
                List <MoveInfo> moves = new List <MoveInfo>();
                moves.AddRange(mPendingMoves);
                mMovesList.Add(moves);
                mPendingMoves.Clear();
                Runnable mover = () =>
                {
                    foreach (MoveInfo moveInfo in moves)
                    {
                        animateMoveImpl(moveInfo.holder, moveInfo.fromX, moveInfo.fromY, moveInfo.toX, moveInfo.toY);
                    }
                    moves.Clear();
                    mMovesList.Remove(moves);
                };
                if (removalsPending)
                {
                    View view = moves[0].holder.itemView;
                    ViewCompat.postOnAnimationDelayed(view, mover, RemoveDuration);
                }
                else
                {
                    mover.run();
                }
            }
            // Next, change stuff, to run in parallel with move animations
            if (changesPending)
            {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.ArrayList<ChangeInfo> changes = new java.util.ArrayList<ChangeInfo>();
                List <ChangeInfo> changes = new List <ChangeInfo>();
                changes.AddRange(mPendingChanges);
                mChangesList.Add(changes);
                mPendingChanges.Clear();
                Runnable changer = () =>
                {
                    foreach (ChangeInfo change in changes)
                    {
                        animateChangeImpl(change);
                    }
                    changes.Clear();
                    mChangesList.Remove(changes);
                };
                if (removalsPending)
                {
                    RecyclerView.ViewHolder holder = changes[0].oldHolder;
                    ViewCompat.postOnAnimationDelayed(holder.itemView, changer, RemoveDuration);
                }
                else
                {
                    changer.run();
                }
            }
            // Next, add stuff
            if (additionsPending)
            {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.ArrayList<android.support.v7.widget.RecyclerView.ViewHolder> additions = new java.util.ArrayList<android.support.v7.widget.RecyclerView.ViewHolder>();
                List <RecyclerView.ViewHolder> additions = new List <RecyclerView.ViewHolder>();
                additions.AddRange(mPendingAdditions);
                mAdditionsList.Add(additions);
                mPendingAdditions.Clear();
                Runnable adder = () =>
                {
                    foreach (RecyclerView.ViewHolder holder in additions)
                    {
                        animateAddImpl(holder);
                    }
                    additions.Clear();
                    mAdditionsList.Remove(additions);
                };
                if (removalsPending || movesPending || changesPending)
                {
                    long removeDuration = removalsPending ? RemoveDuration : 0;
                    long moveDuration   = movesPending ? MoveDuration : 0;
                    long changeDuration = changesPending ? ChangeDuration : 0;
                    long totalDelay     = removeDuration + Math.Max(moveDuration, changeDuration);
                    View view           = additions[0].itemView;
                    ViewCompat.postOnAnimationDelayed(view, adder, totalDelay);
                }
                else
                {
                    adder.run();
                }
            }
        }
Пример #21
0
 public T call()
 {
     task.run();
     return(result);
 }
Пример #22
0
 public void run()
 {
     pointStatment.run();
 }