コード例 #1
0
        private async void LoadDataAsync(object sender, EventArgs e)
        {
            TextStatusProgress.Clear();

            try
            {
                CheckInputLoadDataParameters();

                DisableConfigurationLoadDataButtons();

                threadInformationDataLoaded.Clear();

                TaskCreationOptions taskCreationOptions = TaskCreationOptions.None;
                Enum.TryParse(this.comboTaskCreationOpt.SelectedItem?.ToString(), out taskCreationOptions);

                linqPerformanceManager.ClearLoadedData();

                Stopwatch watch = Stopwatch.StartNew();
                await Task.Run(() => { linqPerformanceManager.LoadData(elementsForLoad, numberOfThreads, taskCreationOptions); });

                watch.Stop();

                TextStatusProgress.Text += Environment.NewLine + $"Memory usage: {System.GC.GetTotalMemory(forceFullCollection:true)/ MB_RATIO} MB";
                TextStatusProgress.Text += Environment.NewLine + $"All items loaded in {watch.ElapsedMilliseconds.ToString()} ms!!";
                TextStatusProgress.Text += Environment.NewLine + $"Processor cores: {Environment.ProcessorCount}";
                TextStatusProgress.Update();

                ButtonNoParallelLinq.Enabled = true;
                ButtonParalellLinq.Enabled   = true;
            }
            catch (Exception exception)
            {
                TextStatusProgress.Text = BuildTraceException(exception);
            }
        }
コード例 #2
0
        private void RestartButton_Click(object sender, EventArgs e)
        {
            inputNumberValues.Enabled   = true;
            numberOfThreadInput.Enabled = true;

            LoadDataButton.Enabled = true;

            textNoParalellAsyn.Clear();
            ButtonNoParallelLinq.Enabled = false;

            textParallelAsym.Clear();
            ButtonNoParallelLinq.Enabled = false;
            ButtonParalellLinq.Enabled   = false;

            comboTaskCreationOpt.Enabled = true;

            TextStatusProgress.Clear();

            this.linqPerformanceManager.ClearLoadedData();
        }