PerCVoice.restart C# (CSharp) Method

restart() public method

public restart ( ) : void
return void
    public void restart()
    {
        //shut down the thread
        if(myThread!=null){
            keepLooping = false;
            Thread.Sleep(5);
            myThread.Join();
            myThread = null;
        }

        //shut down the pipeline
        if(myPipe != null){
            myPipe.Dispose();
            myPipe = null;
        }

        myPipe = new PXCUPipeline();

        commandsSet = myPipe.SetVoiceCommands(commands);
        if(!commandsSet)Debug.Log("Failed to set Commands! :'(");
        if(!myPipe.Init(myMode) || !commandsSet){
            Debug.LogError("Failed To initialize PipeLine OH NOES!");
            initiated = false;
            return;
        }
        else {initiated = true; myPipe.SetDeviceProperty(audio_mix_prop,volume);}//must choose a volume that handles the environment, sensitive mic

        //default the bool arrays to false.
        numbers = new bool[10];
        options = new bool[commands.Length-10];
        for(int i = 0; i<numbers.Length;i++)numbers[i] = false;
        for(int j = 0; j<options.Length;j++)options[j] = false;

        keepLooping = true;//tell the thread not to stop
        dictated	= null;

        myThread = new Thread(ThreadFunc);//make thread handle
        myThread.Start();				  //let 'er rip!

        PerCGesture.PG.restart();
    }