public void SingleThread()
        {
            Counter c = new Counter();
            ThreadManager tt = new ThreadManager();
            tt.AddThreadAction(
                delegate
                    {
                        c.Increment();
                    });

            tt.RunBehavior=ThreadRunBehavior.RunUntilAllThreadsFinish;
            tt.StartAllThreads(500);
            Assert.IsTrue(tt.LastRunTime<tt.TimeOut);
        }
        public void SingleThreadForSpecifiedTimeStrategy()
        {
            Counter c = new Counter();
            ThreadManager tt = new ThreadManager();
            tt.AddThreadAction(
                delegate
                    {
                        c.Increment();
                    });

            tt.RunBehavior = ThreadRunBehavior.RunForSpecificTime;
            tt.StartAllThreads(500);
            Assert.IsTrue(tt.LastRunTime >499,"runtime was "+ tt.LastRunTime);
        }
            public void ShouldInvokeTheGivenActionOnStaThread()
            {
                var threadManager = new ThreadManager();

                var currentThread = Thread.CurrentThread;

                Thread executedThread = null;
                ApartmentState? apartmentState = null;
                threadManager.RunInSTA(() =>
                {
                    executedThread = Thread.CurrentThread;
                    apartmentState = executedThread.GetApartmentState();
                });

                executedThread.ShouldNotBeSameAs(currentThread);
                apartmentState.ShouldEqual(ApartmentState.STA);
            }
        public void Singlton_MultiThreaded_SameInstance()
        {
            ThreadManager tt = new ThreadManager();
            Guid guid1 = Guid.Empty,
                guid2 = Guid.Empty;

            tt.AddThreadAction(delegate
                                   {
                                       guid1 = Singlton.Instance.guid;
                                   });
            tt.AddThreadAction(delegate
                                   {
                                       guid2 = Singlton.Instance.guid;
                                   });

            tt.StartAllThreads(1000);
            Assert.AreEqual(guid1.ToString(),guid2.ToString());
        }
        public void HundredThreads()
        {
            Counter c = new Counter();
            ThreadManager tt = new ThreadManager();
            for (int i = 0; i < 100; i++)
            {
                tt.AddThreadAction(delegate
                                       {
                                           for (int j = 0; j < 10; j++)
                                           {
                                               c.Increment();
                                               Thread.Sleep(new Random(j+1).Next(100,300));
                                           }
                                       });
            }

            //this test will run for 22.5 seconds
            tt.RunBehavior=ThreadRunBehavior.RunForSpecificTime;
            tt.StartAllThreads(22500);
        }
        public void StartAllThreads_exceptionsInThreads_FoundInExceptionsProperty()
        {
            ThreadManager tt = new ThreadManager();
            tt.AddThreadAction(delegate
                                   {
                                       throw  new Exception("forced exception 1");
                                   });
            tt.AddThreadAction(delegate
                                   {
                                       throw  new Exception("forced exception 2");
                                   });
            tt.AddThreadAction(delegate
                                   {
                                       throw  new Exception("forced exception 3");
                                   });

            tt.StartAllThreads(1000);
            Assert.AreEqual(3,ThreadManager.exceptions.Count);
        }
        public void TryToCreateARaceCondition()
        {
            Counter c = new Counter();
            ThreadManager tt = new ThreadManager();
            for (int i = 0; i < 100; i++)
            {
                tt.AddThreadAction(
                    delegate
                        {
            //                            Console.WriteLine(Thread.CurrentThread.Name);
                            for (int j = 0; j < 100000; j++)
                            {
                                c.Increment();
                            }
                        });
            }

            tt.StartAllThreads(5000);
            Assert.AreEqual(1000000,c.Count);
        }
        public void StopWhenTrue_StopAfterCountReaches1000()
        {
            Counter c = new Counter();
            ThreadManager tt = new ThreadManager();
            tt.RunBehavior=ThreadRunBehavior.RunForSpecificTime;
            tt.AddThreadAction(delegate
                                       {
                                           for (int j = 0; j < 103; j++)
                                           {
                                               c.Increment();
                                           }
                                           Thread.Sleep(50);
                                       });

            tt.StopWhenTrue(delegate
                                {
                                    Console.WriteLine("currently at " + c.Count);
                                    return c.Count > 1000;
                                },100);

            tt.StartAllThreads(10000);
            Assert.Greater(c.Count,1000);
            Assert.Less(c.Count,1050);
        }
Beispiel #9
0
        private void ActionEvaluateSelectedDICOMCommunication()
        {
            ArrayList selectedConnection = new ArrayList();
            selectedConnection.Add(comboBoxConnections.SelectedItem);
            //
            // Set the correct settings for the DicomThread.
            //
            String resultsFileBaseName = "DICOMNetworkAnalyzer";
            ThreadManager threadManager = new ThreadManager();

            HLIThread hliThread = new HLIThread(this,dvtkSnifferSession,selectedConnection);
            hliThread.Initialize(threadManager);
            hliThread.Options.ResultsDirectory = CurrentBaseFileName;
            hliThread.Options.Identifier = resultsFileBaseName;
            hliThread.Options.ResultsFileNameOnlyWithoutExtension = resultsFileBaseName;
            hliThread.Options.LogChildThreadsOverview = false;
            hliThread.Options.LogThreadStartingAndStoppingInParent = false;
            hliThread.Options.LogWaitingForCompletionChildThreads  = false;

            // Set the progress bar to minimum
            progressBarStatusBar.Minimum = 0;
            progressBarStatusBar.Maximum = 100;
            progressBarStatusBar.Step = 10;

            //
            // Start the DicomThread.
            //
            hliThread.Start();

            hliThread.WaitForCompletion();

            // Set the progress bar to maximum
            progressBarStatusBar.Value = progressBarStatusBar.Maximum;

            //Display results
            dvtkSummaryWebBrowserSniffer.Navigate(summaryXmlFullFileName);

            if (generateDetailedValidation)
            {
                dvtkDetailWebBrowserSniffer.Navigate(detailXmlFullFileName);
            }

            if(menuItemAnalysisMode.Checked)
                DisplayTabs();
        }
Beispiel #10
0
        private void ActionEvaluateAllDICOMAssociations()
        {
            foreach(object item in comboBoxConnections.Items)
                connectionList.Add(item);

            //
            // Set the correct settings for the DicomThread.
            //
            String resultsFileBaseName = "DICOMNetworkAnalyzer";
            ThreadManager threadManager = new ThreadManager();

            HLIThread hliThread = new HLIThread(this,dvtkSnifferSession,connectionList);
            hliThread.Initialize(threadManager);
            hliThread.Options.ResultsDirectory = CurrentBaseFileName;
            hliThread.Options.Identifier = resultsFileBaseName;
            hliThread.Options.ResultsFileNameOnlyWithoutExtension = hliThread.Options.Identifier;

            // Set the progress bar to minimum
            //progressBarStatusBar.Visible = true;
            progressBarStatusBar.Minimum = 0;
            progressBarStatusBar.Maximum = 100;
            progressBarStatusBar.Step = 100/(connectionList.Count);

            statusBarSniffer.Text = "Please Wait......, Evaluation is in progress";
            Cursor.Current = Cursors.WaitCursor;

            //
            // Start the DicomThread.
            //
            hliThread.Start();

            hliThread.WaitForCompletion();

            // Set the progress bar to maximum
            progressBarStatusBar.Value = progressBarStatusBar.Maximum;

            statusBarSniffer.Text = "Evaluation finished";

            Cursor.Current = Cursors.Default;

            activityLog.Close();

            //Display results
            detailXmlFullFileName = hliThread.Options.DetailResultsFullFileName;
            analysisDlg.ShowResults(detailXmlFullFileName, activityLogFileName);

            menuItemEvaluateComm.Enabled = false;
            evaluateAllAssociations = false;

            if( captureFromFile && (capFileSniffer != null))
            {
                // Stop the low level sniffer
                capFileSniffer.Stop();
            }
        }
Beispiel #11
0
		public void Run ()
		{
			if (current_run != null) {
				if (WarnAndQueryExistingRun ())
					return;
				Abort ();
			}
			current_run = new XsltDebuggerSession (this);
			thread_manager = new ThreadManager (current_run);

			// set breakpoints
			current_run.Executed += OnExecute;

			thread_manager.StartTransform ();
		}