BuildIt.Media.BaseCortanaBackgroundTask.Run C# (CSharp) Метод

Run() публичный Метод

public Run ( IBackgroundTaskInstance taskInstance, VoiceCommandServiceConnection vsc ) : Task
taskInstance IBackgroundTaskInstance
vsc VoiceCommandServiceConnection
Результат Task
        public async Task<bool> Run(IBackgroundTaskInstance taskInstance, VoiceCommandServiceConnection vsc)
        {
            VoiceServiceConnection = vsc;
            serviceDeferral = taskInstance.GetDeferral();
            taskInstance.Canceled += OnTaskCanceled;

            var triggerDetails = taskInstance.TriggerDetails as AppServiceTriggerDetails;
            
            if (triggerDetails == null)
            {
                serviceDeferral.Complete();
                return false;
            }

            try
            {
                if (VoiceServiceConnection == null)
                {
                    VoiceServiceConnection = VoiceCommandServiceConnection.FromAppServiceTriggerDetails(triggerDetails);
                    VoiceServiceConnection.VoiceCommandCompleted += OnVoiceCommandCompleted;

                    var voiceCommand = await VoiceServiceConnection.GetVoiceCommandAsync();

                    //Find the command name witch should match the VCD
                    if (voiceCommand.CommandName == "buildit_help")
                    {
                        //var props = voiceCommand.Properties;
                        await CortanaHelpList();
                        return true;
                    }
                    //await Task.Delay(1000);
                    //await ShowProgressScreen();
                    return false;
                }
                else
                {
                    var voiceCommand = await VoiceServiceConnection.GetVoiceCommandAsync();

                    //Find the command name witch should match the VCD
                    if (voiceCommand.CommandName == "buildit_help")
                    {
                        //var props = voiceCommand.Properties;
                        await CortanaHelpList();
                        return true;
                    }
                    //await Task.Delay(1000);
                    //await ShowProgressScreen();
                    return false;
                }

            }
            catch(Exception ex)
            {
                ex.LogException();
                Debug.WriteLine("Unable to process voice command");
                return false;
            }
            finally
            {
                serviceDeferral.Complete();
            }

        }

Same methods

BaseCortanaBackgroundTask::Run ( IBackgroundTaskInstance taskInstance ) : void