Esempio n. 1
0
        public void Run(IBackgroundTaskInstance taskInstance)
        {
            //Async : deferral
            BackgroundTaskDeferral _deferral = taskInstance.GetDeferral();

                _ifMusicPlaying = false;
                _processService = new ProcessService();

                //打开黑名单: i = 1 => Delay(10000) / 不打开 : i = 0 => delay(2000)
                do
                {
                    var NewProcess = _processService.IfBlackListProcessExist(blackListProgresses, _processService.GetProcessNow());

                    if (NewProcess == false)
                    {
                        if (_ifMusicPlaying == true)
                        {
                            Messenger.Default.Send<StopListenMessage>(new StopListenMessage());
                        }
                        Thread.Sleep(10000);
                    }
                    else
                    {

                        //弹出新窗口
                        PunishWindow();

                        //设置音量50
                        VolumeControl.ChangeVolumeTotheLevel(0.5);

                        //播放音乐
                        if (_ifMusicPlaying == false)
                        {
                            Messenger.Default.Send<BeginListenMessage>(new BeginListenMessage());
                        }

                        Thread.Sleep(2000);
                    }

                    if (_listenFlag == false)
                    {
                        break;
                    }
                }
                while (true);
            }