Пример #1
0
        /// <summary>
        /// Метод для запуска тестирования
        /// </summary>
        public void Start()
        {
            if (State != TesterState.Stop)
            {
                return;
            }
            OnStart();

            object
                lockObj1 = new object(),
                lockObj2 = new object();

            int dataSetsLength    = DataSets.Count(),
                nextDataSetIndex  = 0,
                completedDataSets = 0;

            for (var ti = 0; ti < ThreadsCount; ti++)
            {
                new Thread(() =>
                {
                    while (true)
                    {
                        DataSet dataSet;
                        lock (lockObj1)
                        {
                            if (nextDataSetIndex >= dataSetsLength)
                            {
                                break;
                            }

                            dataSet = DataSets.ElementAt(nextDataSetIndex++);
                        }

                        Test(dataSet);
                        _speedLogger.Log(dataSet.Rows.Count);

                        lock (lockObj2)
                        {
                            ++completedDataSets;
                        }

                        OnProgress((double)completedDataSets / dataSetsLength);
                    }
                }).Start();
            }
        }