Exemplo n.º 1
0
 public void SetThreads()
 {
     if (!e_abort.WaitOne(0, false))
     {
         int difference = (int)Properties.Settings.Default.ThreadCount - threads.Count;
         lock (threads)
         {
             while (difference < 0)
             {
                 TaskThread victim = threads[0];
                 victim.End();
                 ++difference;
             }
             while (difference > 0)
             {
                 TaskThread t = new TaskThread(this);
                 t.Start();
                 --difference;
             }
         }
     }
     else
     {
         lock (threads)
         {
             foreach (TaskThread tt in threads)
             {
                 tt.End();
             }
         }
     }
 }
Exemplo n.º 2
0
        internal void UnRegisterThread(TaskThread taskThread)
        {
            int newcount = 0;

            lock (threads)
            {
                threads.Remove(taskThread);
                newcount = threads.Count;
                if (!ThreadsActive() && e_abort.WaitOne(0, false))
                {
                    mainForm.BeginInvoke(mainForm.threadended);
                }
            }
        }
Exemplo n.º 3
0
        internal void RegisterThread(TaskThread taskThread)
        {
            int newcount = 0;

            lock (threads)
            {
                threads.Add(taskThread);
                newcount = threads.Count;
            }
            lock (ThreadCountChanged)
            {
                if (ThreadCountChanged != null)
                {
                    //  ThreadCountChanged.(this, new ThreadEventArgs(newcount));
                }
            }
        }