Example #1
0
//
//  Called to finish setting up what is needed to run a test and the start the test running
//
//  NOTE: This is called in the context of the UI (primary) thread
//
        public void RunTest()
        {
            prvLoadSounds();                    // load sound files into memory buffers

        #if WIN_PC_PLATFORM
            // get an instance of the task scheduler for background threads
            var backgroundScheduler = TaskScheduler.Default;

            // get an instance of the UI (foreground thread) task scheduler
            var uiScheduler = TaskScheduler.FromCurrentSynchronizationContext();

            // Create a background thread and run using the private prvRunTest method
            // and using the previously set call back to the UI thread code when done
            Task.Factory.StartNew(delegate { this.prvRunTest(); }, backgroundScheduler).
            ContinueWith(delegate { pTest.GetTestDoneCallBack(); }, uiScheduler);
        #endif

                #if MONO_PC_PLATFORM
            if (null == backThread)
            {
                // Create a background thread to run the test
                backThread = new Thread(new ThreadStart(prvRunTest));
            }

            // Run the test on the background thread
            backThread.Start();

            Thread.Sleep(100);                  // sleep the calling thread for a bit
                #endif
        }