/// <summary> /// Create the specified number of threads which will execute the specified stress /// type for a specified number of iterations /// </summary> /// <param name="args">Arguments obtained from the user which configure the execution /// of the app</param> public void RunStressOperations(ArgumentObject args) { this.DebugPrint("//////////////////////////////////////////////////////////////////////////"); this.DebugPrint("//// Starting the stress operation"); this.DebugPrint("//////////////////////////////////////////////////////////////////////////"); for (uint iters = 0; iters < args.NumOfIterations; iters++) { this.tasks = new Task[args.NumOfTasks]; for (uint taskNum = 0; taskNum < args.NumOfTasks; taskNum++) { Task t = new Task( () => { StressOperation stressOp = new StressOperation(TaskCount); stressOp.Start(args.StressOperation, this, args.IsMultipoint); }); t.Start(); this.tasks[taskNum] = t; } // Wait for all threads to finish execution if (args.StopThreadBeforeJoin) { // TODO: Kill the tasks before join (Haven't found a way to accomplish this) } // Wait on all threads to finish execution Task.WaitAll(this.tasks, 15000); this.tasks = null; } this.CurrentlyRunning = false; this.DebugPrint("//////////////////////////////////////////////////////////////////////////"); this.DebugPrint("//// The stress operation has finished"); this.DebugPrint("//////////////////////////////////////////////////////////////////////////"); }
/// <summary> /// Starts the application with the input provided by the user. /// </summary> /// <param name="sender">Object which initiated the event signal.</param> /// <param name="e">Event data that describes how this page was reached. The Parameter /// property is typically used to configure the page.</param> private void Start_Click(object sender, RoutedEventArgs e) { if (!this.stressManager.CurrentlyRunning) { this.stressManager.CurrentlyRunning = true; // Set OS Logging to true so debug prints are written to the output window of the // Visual Studio Debugger, or set to false to have debug prints written to an // alljoyn.log file in Documents Library AllJoyn.Debug.UseOSLogging(false); AllJoyn.Debug.SetDebugLevel("ALLJOYN", 7); AllJoyn.Debug.SetDebugLevel("ALLJOYN_OBJ", 7); // Get the input from the user ArgumentObject argObj = new ArgumentObject(); argObj.NumOfIterations = (uint)IterationSlider.Value; argObj.NumOfTasks = (uint)TreadSlider.Value; argObj.StopThreadBeforeJoin = StopTreadsSwitch.IsOn; argObj.DeleteBusAttachments = DeleteBusSwitch.IsOn; argObj.IsMultipoint = MultipointSwitch.IsOn; argObj.StressOperation = (StressType)StressTypeComboBox.SelectedValue; if (!argObj.DeleteBusAttachments) { argObj.NumOfIterations = 1; } this.stressManager.RunStressOperations(argObj); } }