Example #1
0
        /// <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));
        }
Example #2
0
        /// <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;
        }
Example #3
0
 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")));
     }
 }
Example #4
0
 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;
         }
     }
 }
Example #5
0
        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);
            }
        }
Example #6
0
 public void RaiseActionCompleted(EventModel eventModel)
 {
     ActionCompleted?.Invoke(this, eventModel);
 }
Example #7
0
 protected virtual void OnActionCompleted(string filename, string actionName)
 {
     ActionCompleted?.Invoke(this, new ActionEventArgs(filename, actionName));
 }
Example #8
0
 protected void TriggerEvent(T data)
 {
     ActionCompleted?.Invoke(data);
 }
Example #9
0
 protected virtual void OnActionCompleted(TimeSpan obj)
 {
     ActionCompleted?.Invoke(obj);
 }
Example #10
0
 protected virtual void OnActionCompleted(EventArgs e)
 {
     ActionCompleted?.Invoke(this, e);
 }