private static void PerformTask() { lock (ActionQueue._lock) { if (ActionQueue.task == null) { ActionQueue.task = Task.Factory.StartNew(delegate() { System.Threading.Thread.CurrentThread.Name ??= "公共队列任务线程"; while (!queue.IsEmpty && ActionQueue.queue.TryDequeue(out WaitAction waitAction)) { if (waitAction != null && !waitAction.IsCompleted) { using (waitAction) { waitAction.Run(); ContinueWith?.Invoke(waitAction); } } } ActionQueue.task = null; }, TaskCreationOptions.LongRunning).ContinueWith(delegate(Task i) { i.Dispose(); }); } } }
private bool Accept <TInput, TMulti, TOutput>(ContinueWith <TInput, TMulti, TOutput> .SingleParser p, BnfStringifyVisitor state) { var children = p.GetChildren().ToList(); state.Append(children[0], " CONTINUEWITH ", children[1]); return(true); }
public void MoveTo(Vector3 target, ContinueWith nextFn) { currentPathToWalk = pathfinder.GetPath(new Vector2(gameObject.transform.position.x, gameObject.transform.position.y), new Vector2(target.x, target.y)); currentPathToWalkIndex = 0; MoveToInternal(currentPathToWalk[0], () => { InternalMoveContinueWith(nextFn); }); }
public bool Validate(TIn input) { var(success, result) = Handler(input); if (!success) { return(false); } return(ContinueWith.Validate(result)); }
public virtual Job Run() { Invoke(); if (ContinueWith != null) { Task.Run(() => ContinueWith.RunAsync()); } return(this); }
public bool Validate(IEnumerable <T> input) { foreach (var x in input) { if (!ContinueWith.Validate(x)) { return(false); } } return(true); }
private static void ProcessRequestQueue() { if (queueIsProcessing) { return; } queueIsProcessing = true; while (requestQueue.Count > 0) { var url = requestQueue.Dequeue(); //D.Log("GoogleAnalytics : start request : " + url); WWW www = new WWW(url); float timeoutCompletion = Time.realtimeSinceStartup + submitTimeout; ContinueWith.When(() => Time.realtimeSinceStartup > timeoutCompletion || www.isDone, () => ProcessRequestResult(www)); } queueIsProcessing = false; }
private void InternalMoveContinueWith(ContinueWith realContinueWith) { ++currentPathToWalkIndex; if (currentPathToWalk.Length <= currentPathToWalkIndex) { if (isMoving) { isMoving = false; animator.SetTrigger("WalkEnd"); } if (realContinueWith != null) realContinueWith(); return; } MoveToInternal(currentPathToWalk[currentPathToWalkIndex], () => { InternalMoveContinueWith(realContinueWith); }); }
private static void ProcessRequestQueue() { if (queueIsProcessing) { return; } queueIsProcessing = true; while (requestQueue.Count > 0) { var url = requestQueue.Dequeue(); //D.Log("GoogleAnalytics : start request : " + url); var form = new WWWForm(); var request = UnityWebRequest.Post(url, form); var asyncOperation = request.SendWebRequest(); float timeoutCompletion = Time.realtimeSinceStartup + submitTimeout; ContinueWith.When(() => Time.realtimeSinceStartup > timeoutCompletion || asyncOperation.isDone, () => ProcessRequestResult(asyncOperation.webRequest)); } queueIsProcessing = false; }
public virtual async Task <Job> RunAsync() { var task = new Task <Job>(new Func <Job>(Invoke)); task.Start(); if (ContinueWith != null) { await task.ContinueWith(t => ContinueWith.RunAsync()); } //if (JobState==AutomatMachine.JobState.Successful && !IsContinuous) //{ // return this; //} //if (Action != null) //{ // var task = new Task(Action); // LastWorkDate = DateTime.Now; // NextWorkDate = DateTime.Now.AddMilliseconds(Interval); // task.Start(); // if (ContinueWith != null) // await task.ContinueWith(t => ContinueWith.RunAsync()); // await task; // NumberOfWorking++; //} await task; return(this); }
public bool IsMatch(Instruction instruction) { if (string.IsNullOrEmpty(Pattern)) { return(false); } if (Pattern == ".") //Self, or same node { if (ContinueWith != null) { return(ContinueWith.IsMatch(instruction)); } else if (ContinueWithFunc != null) { return(ContinueWithFunc(instruction)); } else { return(false); } } if (ContinueWith != null) { var result = instruction.Nearest(Pattern, Direction, Steps); return(ContinueWith.IsMatch(result)); } else if (ContinueWithFunc != null) { var result = instruction.Nearest(Pattern, Direction, Steps); return(ContinueWithFunc(result)); } else { return(instruction.IsNearMethod(Pattern, Direction, Steps)); } }
private void RunContinueWith() { ContinueWith.Run(); }
private void YieldFocuser() { MRS.Reset(); MRS.WaitOne(); ContinueWith?.Invoke(); }
// Call to disable executing of an action after the player reaches the end of his path. public void ClearAfterMoveAction() { currentContinue = null; }
private void MoveToInternal(Vector2 target2D, ContinueWith nextFn) { Vector3 target = new Vector3(target2D.x, target2D.y, gameObject.transform.position.z); target.y += DestinationOffsetY; currentRemainingDistance = Vector3.Distance(gameObject.transform.position, target); if (currentRemainingDistance <= DestinationDelta) { nextFn(); return; } currentTarget = target; currentContinue = nextFn; currentDirection = new Vector3(target.x, target.y, gameObject.transform.position.z) - gameObject.transform.position; // ReSharper disable once CompareOfFloatsByEqualityOperator if (currentDirection.x != 0) SetNewFacing(currentDirection.x < 0 ? Facing.Left : Facing.Right); currentDirection.Normalize(); if (!isMoving) { animator.SetTrigger("WalkStart"); isMoving = true; StartCoroutine(playSteps()); } }