Exemple #1
0
        private void btnStartGeneration_Click(object sender, EventArgs e)
        {
            int start = int.Parse(nudStartKey.Value.ToString(CultureInfo.InvariantCulture));
            int count = int.Parse(nudKeyCount.Value.ToString(CultureInfo.InvariantCulture));

            TimeMeasure.Start();
            try
            {
                for (int i = start; i < start + count; i++)
                {
                    if (_storageClosing)
                    {
                        break;
                    }
                    _storage.Set(i, RandomString(_random.Next(500)));

                    if (i % 1000 == 0)
                    {
                        lblState.Text = $"Inserting value {i}...";
                        Application.DoEvents();
                    }
                }

                if (!_storageClosing)
                {
                    lblState.Text = "Flushing...";
                    Application.DoEvents();
                    _storage.Flush();
                }
            }
            finally
            {
                TimeMeasure.Stop();
            }

            lblState.Text = $"Done! Elapsed time: {TimeMeasure.Result()}";
            TimeMeasure.Reset();
        }