public void Mining(VideoCard card, LocalCurrency lc, bool flag)
 {
     if (flag)
     {
         if (treads.ContainsKey(card))
         {
             return;
         }
         Thread th = new Thread(() => Work(card, lc));
         th.IsBackground = true;
         th.Start();
         treads.Add(card, th);
         card.ActiveTasks++;
     }
     else
     {
         if (!treads.ContainsKey(card))
         {
             return;
         }
         Thread th = treads[card];
         treads.Remove(card);
         th.Abort();
         card.ActiveTasks--;
     }
 }
Exemple #2
0
        void StartAbortMining(VideoCard card, LocalCurrency lc, bool flag)
        {
            GlobalCurrency activeCur = Currencies.FirstOrDefault(curr => curr.Id == lc.Id);

            if (activeCur == null)
            {
                return;
            }
            activeCur.Mining(card, lc, flag);
        }
 void Work(VideoCard card, LocalCurrency lc)
 {
     while (true)
     {
         Thread.Sleep(1000);
         double v = card.Power / card.ActiveTasks / diff / 100000000;
         lock (locker)
         {
             Val += v;
         }
         lc.Val += v;
     }
 }
Exemple #4
0
        public void RemoveCurr(Guid id)
        {
            LocalCurrency lc = Currencies.FirstOrDefault(c => c.Id == id);

            if (lc != null)
            {
                if (lc.IsAct)
                {
                    ActiveTasks--;
                }
                Currencies.Remove(lc);
            }
        }
Exemple #5
0
 void AddRemTask(LocalCurrency lc, bool flag)
 {
     startAbortMining(this, lc, flag);
 }