Можно ли связываться с AppServiceConnection и uwp в WinForm?Ошибка: не содержит определения «GetAwaiter», это мой код: Спасибо!
Это код в WinForm:
private AppServiceConnection calculatorService;
static Form1 mainForm;
public Form1()
{
InitializeComponent();
}
private async void button1_Click(object sender, EventArgs e)
{
//Add the connection
if (calculatorService == null)
{
calculatorService = new AppServiceConnection();
calculatorService.AppServiceName = "com.yanscorp.appservicedemo.Values";
calculatorService.PackageFamilyName = "c97887ad-1f75-4b48-9e3b-21b89c061715_6evysfdvxt248";
var status = await calculatorService.OpenAsync();//A mistake here
if (status != AppServiceConnectionStatus.Success)
{
string d = "Failed to connect";
return;
}
}
var message = new ValueSet();
message.Add("Request", "GetCallCount");
AppServiceResponse response = await calculatorService.SendMessageAsync(message);//A mistake here
string result = "";
if (response.Status == AppServiceResponseStatus.Success)
{
result = response.Message["Response"] as string;
// Get the data that the service sent to us.
textBlock.Text = result;
}
}
Ошибка: 错误 CS4036 «IAsyncOperation» 不 包含 «GetAwaiter» 的 , , 并且 找不到 可接受 类型 «IAsyncOperation»WindowsFormsApplication1