public void InstallerWrongBitness()
        {
            Console.WriteLine("Installer (wrong bitness)");
            BehaviorsRegression.CleanMachine();
            var environmentVariable = Environment.GetEnvironmentVariable("PROCESSOR_ARCHITECTURE");

            if (environmentVariable != null && environmentVariable.Contains("64"))
            {
                var myJob  = new ThreadTest();
                var thread = new Thread(myJob.InstallMsi64)
                {
                    Name = "first"
                };
                thread.Start();
                Thread.Sleep(WaitError + 60000);
                Assert.IsTrue(AT.WindowExists(NameWindowWaring, NameAlert64Bit));
                Calculator.ClickOnButtonByName(NameWindowWaring, "OK");
            }
            else
            {
                var myJob1  = new ThreadTest();
                var thread1 = new Thread(myJob1.InstallMsi32)
                {
                    Name = "Second"
                };
                thread1.Start();
                Thread.Sleep(WaitError);
                Assert.IsTrue(AT.WindowExists(NameWindowWaringXp, NameAlert32Bit), "Incorrect warning message");
                Calculator.ClickOnButtonByName(NameWindowWaringXp, "OK");
            }
        }
Example #2
0
        private void button2_Click(object sender, EventArgs e)
        {
            //创建无参数方法的托管线程
            //创建线程
            Thread thread1 = new Thread(new ThreadStart(method));

            //启动线程
            thread1.Start();
            ThreadTest test = new ThreadTest();
            //创建线程
            Thread thread2 = new Thread(new ThreadStart(test.MyThread));

            //启动线程
            thread2.Start();
            Thread thread3 = new Thread(delegate() { Console.WriteLine("我是通过匿名委托创建的线程"); });

            thread3.Start();

            //通过Lambda表达式创建
            Thread thread4 = new Thread(() => { Console.WriteLine("我是通过Lambda表达式创建的委托"); });

            thread4.Start();
            //通过ParameterizedThreadStart创建线程
            Thread thread = new Thread(new ParameterizedThreadStart(Thread1));

            //给方法传值
            thread.Start("这是一个有参数的委托");
        }
Example #3
0
    static void Main()
    {
        ThreadTest b = new ThreadTest();
        Thread     t = new Thread(b.RunMe);

        t.Start();
    }
Example #4
0
    static bool done; // Static fields are shared between all threads

    #endregion Fields

    #region Methods

    static void Main()
    {
        ThreadTest tt = new ThreadTest();   // Create a common instance
        new Thread(tt.Go).Start();
        tt.Go();

        Console.ReadKey();
    }
Example #5
0
 public static void Main()
 {
     ThreadTest b = new ThreadTest();
     Thread t = new Thread(new ThreadStart(b.runme));
     t.Start();
     Console.WriteLine("main thread");
     Console.ReadLine();
 }
Example #6
0
        private void button_start_Click(object sender, EventArgs e)
        {
            workerObject        = new ThreadTest();
            workerThread        = new Thread(workerObject.MyThread);
            workerThread.Name   = "文件处理线程";
            common.gCurrent_cmd = e_Current_cmd.START_CONVERSION;

            workerThread.Start();
        }
Example #7
0
        public void MeasureThreadCall_None_Equal()
        {
            ThreadTest.CreateNewThread();
            var actual    = tracer.GetTraceResult().Threads;
            var expected  = new MethodTraceResult("ThreadTest", "CreateNewThread");
            var expected1 = new MethodTraceResult("ThreadTest", "NewThreadCall");

            Assert.AreEqual(2, actual.Count);
            CheckEqual(expected, actual[1].Methods[0]);
            CheckEqual(expected1, actual[0].Methods[0]);
        }
Example #8
0
    public static void Main()
    {
        ThreadTest t = new ThreadTest();

        Thread first  = new Thread(t.FirstWork);
        Thread second = new Thread(new ThreadStart(t.SecondWork));

        first.Priority  = ThreadPriority.Lowest;
        second.Priority = ThreadPriority.Highest;

        first.Start();  second.Start();
    }
Example #9
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            var         tt = new ThreadTest();
            ThreadStart ts = new ThreadStart(tt.StartUiThread);
            Thread      t  = new Thread(ts);

            t.Name = "UI Thread";
            t.Start();
            Thread.Sleep(new TimeSpan(0, 0, 10));
        }
Example #10
0
        private static void Main()
        {
            //var fib = new Fib(true);
            //fib.Main();
            //System.Console.ReadKey();
            var test = new ThreadTest();

            test.Main(7);


            //System.Diagnostics.Process.Start();
            //System.Threading.Thread.Sleep(50);
            //System.Threading.Thread.SpinWait(50);
        }
Example #11
0
    static void Main(string[] args)
    {
        ThreadTest myThreadTest = new ThreadTest();
        Thread     myThread     = new Thread(new ThreadStart(myThreadTest.test));

        myThread.Start();
        Thread.Sleep(5000);
        bool status = myThread.Join(1000);

        if (myThread.IsAlive)
        {
            myThread.Abort();
        }
        Thread.Sleep(5000);
    }
Example #12
0
        internal static int AppMain(Parameters !config)
        {
            int result;

            Console.WriteLine("Running MpStress for CPU Count {0}", config.cpuCount);

            ThreadTest tt = new ThreadTest();

            result = tt.RunTest(config.cpuCount, config.passCount);
            if (result != 0)
            {
                return(result);
            }

            return(0);
        }
Example #13
0
    static int Main()
    {
        SimpleReadWriteThreadStaticTest.Run(42, "SimpleReadWriteThreadStatic");

        // TODO: After issue https://github.com/dotnet/corert/issues/2695 is fixed, move FinalizeTest to run at the end
        if (FinalizeTest.Run() != Pass)
        {
            return(Fail);
        }

        ThreadStaticsTestWithTasks.Run();

        if (ThreadTest.Run() != Pass)
        {
            return(Fail);
        }

        return(Pass);
    }
Example #14
0
            static void Main()
            {
                //由於兩線程再同一個 Class實例上調用Go().所以他們共享_done
                //結果打印一個Done
                ThreadTest tt = new ThreadTest(); //創建共同實例

                new Thread(tt.Go).Start();        //線程執行
                tt.Go();                          //主線程執行



                // ThreadStart action = () =>
                // {
                //     if (!done)
                //     {
                //         done = true;
                //         System.Console.WriteLine("Done");
                //     }
                // };
            }
Example #15
0
        protected override void ProcessRecord()
        {
            if (!_drop)
            {
                //string query = "DELETE FROM $" + ProviderUtil.TEST_COLLECTION_NAME + "$";
                //long rowsAffected = _database.ExecuteNonQuery(query);
                Collection <Order> order = _database.GetCollection <Order>(_collectionName);
                WriteObject("\n");
                //order.InsertDocuments(DataLoader.LoadOrders(_initailLoadedValues));


                WriteObject(string.Format("database = {0}, total-loop-count = {1}, test-case-iterations = {2}, testCaseIterationDelay = {3}, gets-per-iteration = {4}, updates-per-iteration = {5}, deletes-per-iteration = {6}, thread-count = {7}, reporting-interval = {8}, max-documents = {9} ."
                                          , _databaseName, TotalIteration, TestCaseIterations, TestCaseIterationDelay, GetsPerIteration, UpdatesPerIteration, DeletesPerIteration, ThreadCount, ReportingInterval, MaxDocuments));
                WriteObject("-------------------------------------------------------------------\n");
                Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.Normal;

                threadTest = new ThreadTest(_connectionString, _collectionName, _threadCount, _totalLoopCount, _testCaseIterations, _testCaseIterationDelay, _getsPerIteration, _updatesPerIteration, _insertsPerIteration, _deletesPerIteration, _reportingInterval, _maxDocouments, this);
                threadTest.Test();
            }
        }
Example #16
0
        private void btn2_Click(object sender, RoutedEventArgs e)
        {
            clearComments();

            //实例化回调
            setCallBack = new setTextValueCallBack(showComment);

            //创建无参的线程
            Thread thread1 = new Thread(new ThreadStart(Thread1));

            //调用Start方法执行线程
            thread1.Start();

            //创建ThreadTest类的一个实例
            ThreadTest test = new ThreadTest(this);
            //调用test实例的MyThread方法
            Thread thread2 = new Thread(new ThreadStart(test.Thread2));

            //启动线程
            thread2.Start();

            //通过匿名委托创建
            Thread thread3 = new Thread(delegate() { update("我是通过匿名委托创建的线程"); });

            thread3.Start();
            //通过Lambda表达式创建
            Thread thread4 = new Thread(() => update("我是通过Lambda表达式创建的委托"));

            thread4.Start();


            //通过ParameterizedThreadStart创建线程
            Thread thread5 = new Thread(new ParameterizedThreadStart(Thread5));

            //给方法传值
            thread5.Start("这是一个有参数的委托");

            //Console.ReadKey();
        }
    static int Main()
    {
        SimpleReadWriteThreadStaticTest.Run(42, "SimpleReadWriteThreadStatic");

        ThreadStaticsTestWithTasks.Run();

        if (ThreadTest.Run() != Pass)
        {
            return(Fail);
        }

        if (TimerTest.Run() != Pass)
        {
            return(Fail);
        }

        if (FinalizeTest.Run() != Pass)
        {
            return(Fail);
        }

        return(Pass);
    }
    private static void Main(string[] args)
    {
        List <Thread> threads = new List <Thread>();
        ThreadTest    tt      = new ThreadTest();

        for (int i = 0; i < 10; i++)
        {
            // alter the varialbe shared
            lock (tt.thisLock)
            {
                Thread t = new Thread(() => tt.DoAction(string.Format("Thread-{0}", i)));
                threads.Add(t);
                t.Start();
            }
        }
        // wait after each thread
        foreach (Thread item in threads)
        {
            item.Join();
        }
        tt.ReadList();

        Console.ReadKey();
    }
Example #19
0
 static void Main(string[] args)
 {
     ThreadTest.Run();
     Console.Program.
 }
Example #20
0
 static void Main(string[] args)
 {
     ThreadTest.Execute4();
     Console.ReadKey();
 }
Example #21
0
        }       /// <summary>
        /// Initialize the Logger
        /// </summary>
        public void ApplicationSetup(Form mainForm, string rootFolder)
        {
            _mainForm = mainForm;
            U.GetDummyControl();
            U.AddThread("Main GUI");
            {
                ThreadTest test = new ThreadTest();
                test = null;
            }
            GC.Collect();
            GC.WaitForPendingFinalizers();

            AppStatus("Initialize CPU Counter");
            _cpuCounter = new PerformanceCounter();

            _cpuCounter.CategoryName = "Processor";
            _cpuCounter.CounterName  = "% Processor Time";
            _cpuCounter.InstanceName = "_Total";
            string zero = CPUPerc;           // First one is zero

            U.DumpProcessUsage("AppSetup1"); // Dump Processes running
            string   rawVer           = "Unknown";
            string   title            = "Unknown Title";
            Assembly entryAssembly    = Assembly.GetEntryAssembly();
            Version  version          = entryAssembly.GetName().Version; //.Getatt(typeof(AssemblyVersionAttribute), true);
            string   ReleaseCandidate = "Official";

            if (version.Revision != 0)
            {
                ReleaseCandidate = string.Format("Release Candidate {0}", version.Revision);
            }
            rawVer = string.Format("{0}.{1} Build {2} ({3})", version.Major, version.Minor, version.Build, ReleaseCandidate);

            object[] attrs = entryAssembly.GetCustomAttributes(typeof(AssemblyTitleAttribute), true);
            if (attrs != null && attrs.Length > 0)
            {
                title = ((AssemblyTitleAttribute)attrs[0]).Title;
            }

            attrs = entryAssembly.GetCustomAttributes(typeof(AssemblyReleaseNotesAttribute), true);
            if (attrs != null && attrs.Length > 0)
            {
                _releaseNotes           = ((AssemblyReleaseNotesAttribute)attrs[0]).ReleaseNotes;
                mainForm.HelpRequested += new System.Windows.Forms.HelpEventHandler(this.OnHelp);
            }
            _titleText = string.Format("{0} - Ver {1}", title, rawVer);

            U.LogInfo("Application Loading : {0}", _titleText);

            AppStatus("Application Setup");


            U.DumpProcessUsage("AppSetup2");  // Dump Processes running

            if (rootFolder.EndsWith("\\"))
            {
                rootFolder = rootFolder.Substring(0, rootFolder.Length - 1);
            }
            RootFolder       = rootFolder;
            U.s_mainThreadId = Thread.CurrentThread.ManagedThreadId;

            // Handling UI thread unhandle exceptions.
            Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(ApplicationUI_ThreadException);

            // Add the event handler for handling non-UI thread exceptions to the event.
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);


            // Get all non-system loaded assemblies
            Assembly[] loadedAssemblies = AppDomain.CurrentDomain.GetAssemblies();
            Dictionary <string, Assembly> loadedNames = new Dictionary <string, Assembly>();

            foreach (Assembly assembly in loadedAssemblies)
            {
                AssemblyName assemblyName = new AssemblyName(assembly.FullName);
                if (!assemblyName.Name.StartsWith("System") &&
                    !assemblyName.Name.StartsWith("mscorlib") &&
                    !assemblyName.Name.StartsWith("vshost32") &&
                    !assemblyName.Name.StartsWith("Microsoft"))
                {
                    loadedNames.Add(assemblyName.Name, assembly);
                }
            }
            // Now get all references asswemblies
            AddReferencedAssemblies(entryAssembly, loadedNames);

            List <Type> controlTypes = new List <Type>();

            s_loadedCompTypes.Add(typeof(CompBase));

            foreach (Assembly assembly in loadedNames.Values)
            {
                Type[] assemblyTypes = assembly.GetTypes();
                s_loadedCompTypes.AddRange(assemblyTypes.Where(t => t.IsClass && t.IsSubclassOf(typeof(CompBase))));
                controlTypes.AddRange(assemblyTypes.Where(t => t.IsClass && t.IsSubclassOf(typeof(Control))));
            }

            #region Load all component types from plug in


            U.EnsureDirectory(_rootFolder);
            U.EnsureDirectory(PluginFolder);
            foreach (string dll in Directory.GetFiles(PluginFolder, "*.dll"))
            {
                Assembly assemblyPlugIn = Assembly.LoadFrom(dll);
                Type[]   assemblyTypes  = null;
                try
                {
                    assemblyTypes = assemblyPlugIn.GetTypes();
                    s_pluginCompTypes.AddRange(assemblyTypes.Where(t => t.IsClass && t.IsSubclassOf(typeof(CompBase))));
                    controlTypes.AddRange(assemblyTypes.Where(t => t.IsClass && t.IsSubclassOf(typeof(Control))));
                    U.LogInfo("PlugIn loaded: {0}", assemblyPlugIn.FullName);
                }
                catch (Exception ex)
                {
                    U.LogPopup("PlugIn Failed: {0}  Reason: {1}", assemblyPlugIn.FullName, ex.Message);
                }
            }

            CreateSimClasses();

            AppStatus("Adding Control Pages");
            AddControlPages(controlTypes);

            #endregion

            U.LogInfo("StopWatch Resolution={0}", Stopwatch.IsHighResolution);
            U.LogInfo("StopWatch Frequency={0}", Stopwatch.Frequency);

            U.DumpProcessUsage("End AppSetup");  // Dump Processes running
        }
 static void Main()
 {
     ThreadTest b = new ThreadTest();
         Thread t = new Thread(b.RunMe);
         t.Start();
 }