Как использовать «AppServiceConnection» для общения в «WinForm» - PullRequest
0 голосов
/ 06 июня 2018

Как использовать "AppServiceConnection" для связи в "WinForm"

Это мой код, но он не может быть выполнен

AppServiceConnection appService = new AppServiceConnection();
        appService.AppServiceName = "com.yanscorp.appservicedemo.Values";
        appService.PackageFamilyName = "c97887ad-1f75-4b48-9e3b-21b89c061715_6evysfdvxt248";

        //if used "await" Error:"IAsyncOperation" does not contain the definition of "GetAwaiter".
        //var status = await appService.OpenAsync();

        //Remove "await"
        var status = appService.OpenAsync();

        //but run status.GetResults(),throw: invoking a method at an unexpected time
        if (status.GetResults() == AppServiceConnectionStatus.Success)
        {
            string d = "Failed to connect";
            return;
        }

        var message = new ValueSet();
        message.Add("Request", "GetCallCount");
        //if used "await" Error:"IAsyncOperation" does not contain the definition of "GetAwaiter".
        //AppServiceResponse response = await appService.SendMessageAsync(message);

        //Remove "await"
        var s = appService.SendMessageAsync(message);

        //but run status.GetResults(),throw: invoking a method at an unexpected time
        AppServiceResponse response = s.GetResults();
        string result = "";

        if (response.Status == AppServiceResponseStatus.Success)
        {
            result = response.Message["Response"] as string;
            textBlock.Text = result;
        }

Пожалуйста, пожалуйста, помогите мне, спасибо

1 Ответ

0 голосов
/ 27 ноября 2018

Вы не ссылались на Систему.Поставьте using System; поверх вашего кода

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...