/// <summary> /// Прошивка выполняется в параллельном потоке /// </summary> public void ActionThread() { var Result = Executer.Exec(Env, Tool, Project, Script, Script.Actions[Action], CompiledArgs); Debug.WriteLine(String.Format(" {0:s}: {1:s}", (Result.Result != ExecResultType.Error) ? "OK" : "FAIL", Result.Message)); ActionCompleted?.Invoke(this, new ActionEventArgs(Action, Result)); }
/// <summary> /// Init this task /// </summary> private void GenerateAction() { byte[] buffer; int blockNumber; lock (Instance) buffer = Source.GetPortionData(out blockNumber); Action calcHashFunc = () => { int blockNum = blockNumber; byte[] block = buffer; using (var sha256 = SHA256.Create()) { var hashedBytes = sha256.ComputeHash(block); var hash = BitConverter.ToString(hashedBytes).Replace("-", string.Empty).ToLower(); string res = $"{blockNum} ->{block.Length} ->{Thread.CurrentThread.ManagedThreadId} ->{hash}"; Result = TaskWriteObjectToFile.GetInstance(StringSource.GetInstance(res)); ActionCompleted?.Invoke(this); } }; ActionToRun = calcHashFunc; }
public void RunAction(int Index) { Action = Index; Cancelled = false; if (Index < Script.Actions.Count) { Thread Thr = new Thread(ActionThread); Thr.Start(); } else { ActionCompleted?.Invoke(this, new ActionEventArgs(Action, new ERError("Invalid action index"))); } }
private void Move(ref float p1, float p2) { if (p1 != p2) { int mult = (p1 < p2) ? 1 : -1; float inc = _speed * mult; if (Math.Abs(p1 - p2) <= _speed) { p1 = p2; IsDestroyed = true; ActionCompleted.Invoke(this, new EventArgs()); } else { p1 += inc; } } }
public void OnShoot() { while (true) { if (rng.Next(0, 100) % 2 == 0) { if (ActionCompleted != null) { ActionCompleted.Invoke(this, EventArgs.Empty); } } else { Console.WriteLine("Missed"); } Thread.Sleep(500); } }
public void RaiseActionCompleted(EventModel eventModel) { ActionCompleted?.Invoke(this, eventModel); }
protected virtual void OnActionCompleted(string filename, string actionName) { ActionCompleted?.Invoke(this, new ActionEventArgs(filename, actionName)); }
protected void TriggerEvent(T data) { ActionCompleted?.Invoke(data); }
protected virtual void OnActionCompleted(TimeSpan obj) { ActionCompleted?.Invoke(obj); }
protected virtual void OnActionCompleted(EventArgs e) { ActionCompleted?.Invoke(this, e); }