private static async void InventoryService_RequestReceived(AppServiceConnection sender, AppServiceRequestReceivedEventArgs args) { BaseCommandResult result = null; var command = MessagingUtils.UnpackCommand <BaseCommand>(args.Request.Message); if (command is CheckCommand) { var checkResult = new CheckResult(); SysInfo.Fill(checkResult); SpeculationControl.Fill(checkResult); result = checkResult; } else { result = new ErrorResult(); } await args.Request.SendResponseAsync(MessagingUtils.PackResult <ValueSet>(result)); // close app after each command m_appServiceExit.Set(); }