private void InteractWithUI(ref DiskResults results, MainWindow ui)
        {
            string desc = results.Description;

            ui.Dispatcher.InvokeAsync(() => {
                ui.txtResults.AppendText($"Successfully ran the DISK test! Below is the " +
                                         $"results of the test.\n\n" +
                                         $"{desc}\n\n" +
                                         $"\n\n");
            });

            ui.Dispatcher.InvokeAsync(() => {
                ui.txtBlkResults.Text = "Results for the DISK test are below! If you would " +
                                        "like to send the results to the database, right click the results and press " +
                                        "send to database!";
            });

            ui.Dispatcher.InvokeAsync(() => {
                ui.ShowTabWindow(Tab.RESULTS);
                ui.btnRunTheTest.IsEnabled = true;
                ui.txtBlkRunningTest.Text  = "Are you sure you want to run this test?";
                ui.txtResults.ScrollToVerticalOffset(0);
                ui.txtBlkRunningTestTips.Visibility = System.Windows.Visibility.Hidden;
                ThemeManager.StopRunningTest();
            });
        }
Beispiel #2
0
        /// <summary>
        /// Runs the benchmarking test on the DISK
        /// with a particular <see cref="ThreadType"/>.
        /// </summary>
        /// <param name="threadType">The type of threading
        /// for the test.</param>
        /// <returns>A new <see cref="DiskFunctions"/> instance
        /// containing the result.</returns>
        /// <param name="userData">The <see cref="UserData"/> thats passed
        /// into the instance for user information but is marked
        /// <see langword="readonly"/> internally.</param>
        /// <param name="ui">The <see cref="MainWindow"/> instance thats passed
        /// into for UI related tasks for updating components in it.</param>
        /// <exception cref="RipperThreadException"></exception>

        public void RunDiskBenchmark(ThreadType threadType, ref UserData userData, MainWindow ui)
        {
            var results = new DiskResults(this.rs, ref userData);

            switch (threadType)
            {
            case ThreadType.Single:
            {
                // runs task on main thread.
                RunTestsSingle(ref results);

                InteractWithUI(ref results, ui);

                break;
            }

            case ThreadType.SingleUI:
            {
                // runs task, but doesn't wait for result.

                void a()
                {
                    RunTestsSingleUI(ref results, ui);
                }

                Task task = new Task(a);

                task.Start();

                break;
            }

            case ThreadType.Multithreaded:
            {
                break;
            }

            default:
            {
                throw new RipperThreadException("Unknown thread type to call. " +
                                                "public DiskResults RunDiskBenchmark(ThreadType threadType) " +
                                                "in function.DiskFunctions ");
            }
            }
        }
        /// <summary>
        /// Runs each test <see cref="RipperSettings.IterationsPerDiskTest"/> times.
        /// <para>Should be (<see cref="DiskResults.UniqueTestCount"/> *
        /// <see cref="RipperSettings.IterationsPerDiskTest"/>)
        /// timespans in <see cref="DiskResults.TestCollection"/>.</para>
        /// </summary>
        /// <param name="results">The <see cref="DiskResults"/> by reference
        /// to add the <see cref="TimeSpan"/>(s).</param>

        private void RunTestsSingle(ref DiskResults results)
        {
            for (byte b = 0; b < this.rs.IterationsPerDiskTest; b++)
            {
                results.TestCollection.Add(RunFolderMatrix());
            }

            for (byte b = 0; b < this.rs.IterationsPerDiskTest; b++)
            {
                results.TestCollection.Add(RunBulkFile());
            }

            for (byte b = 0; b < this.rs.IterationsPerDiskTest; b++)
            {
                results.TestCollection.Add(RunReadWriteParse());
            }

            for (byte b = 0; b < this.rs.IterationsPerDiskTest; b++)
            {
                results.TestCollection.Add(RunDiskRipper());
            }
        }
        /// <summary>
        /// Runs each test <see cref="RipperSettings.IterationsPerDiskTest"/> times.
        /// <para>Should be (<see cref="DiskResults.UniqueTestCount"/> *
        /// <see cref="RipperSettings.IterationsPerDiskTest"/>)
        /// timespans in <see cref="DiskResults.TestCollection"/>.</para>
        /// </summary>
        /// <param name="results">The <see cref="DiskResults"/> by reference
        /// to add the <see cref="TimeSpan"/>(s).</param>
        /// <param name="ui">The <see cref="MainWindow"/> instance thats passed
        /// into for UI related tasks for updating components in it.</param>

        private void RunTestsSingleUI(ref DiskResults results, MainWindow ui)
        {
            for (byte b = 0; b < this.rs.IterationsPerDiskTest; b++)
            {
                results.TestCollection.Add(RunFolderMatrix());
            }

            for (byte b = 0; b < this.rs.IterationsPerDiskTest; b++)
            {
                results.TestCollection.Add(RunBulkFile());
            }

            for (byte b = 0; b < this.rs.IterationsPerDiskTest; b++)
            {
                results.TestCollection.Add(RunReadWriteParse());
            }

            for (byte b = 0; b < this.rs.IterationsPerDiskTest; b++)
            {
                results.TestCollection.Add(RunDiskRipper());
            }

            InteractWithUI(ref results, ui);
        }