pplawait.h / экспериментальный / возобновляемый для co_await не работает

Я установил на Windows 10.0 Visual Studio 2017 (версия 15.2)
Я перенес с VS2013 на VS2017 для своего проекта (который включает в себя cpprestsdk) и изменил метод .then () с помощью co_await. Я прочитал что-то в Интернете, но на самом деле я больше не могу скомпилировать свое решение.
Не удается открыть включаемый файл pplawait.h
игнорирование неизвестного опиона ‘/ await’

Предложения?

0

Решение

Использование сопрограмм с Visual Studio 2017 и решения MFC, в котором я использую C ++ / WinRT с его async Тип функций у меня следующий.

Смотрите также этот вопрос и мой ответ, который содержит несколько примеров использования сопрограмм с concurrency, std:async и C ++ / WinRT: Потоки C ++ 11 для обновления окон приложений MFC. SendMessage (), PostMessage () требуется?

Прежде всего настройки в свойствах решения.

  • Свойства конфигурации -> Общие -> Набор инструментов платформы Visual Studio 2017 (v141)
  • C / C ++ -> Все параметры -> Дополнительные параметры -> / await
  • C / C ++ -> Все параметры -> Стандарт языка C ++ Стандарт ISO C ++ 17 (/ stdc ++ 17)

настройки для Свойства - Свойства конфигурации

настройки свойств - C / C ++ (настройки компилятора)

И исходный код для фактической функции, которую я использую (асинхронная функция C ++ / WinRT с co_await):

#include <pplawait.h>

#pragma comment(lib, "windowsapp")
#include "winrt/Windows.Foundation.h"#include "winrt/Windows.Web.Syndication.h"
// . . .  other code

// sample function using co_await to retrieve an RSS feed which may take
// a while so we want to start it and then continue when the results are
// received. we are using one of the async functions of C++/WinRT to retrieve
// the RSS feed text. We require a pointer to a CMainFrame object which has
// the function we need to output the text lines to a displayed window.
winrt::Windows::Foundation::IAsyncAction myTaskMain(CMainFrame *p)
{
winrt::Windows::Foundation::Uri uri(L"http://kennykerr.ca/feed");
winrt::Windows::Web::Syndication::SyndicationClient client;
winrt::Windows::Web::Syndication::SyndicationFeed feed = co_await client.RetrieveFeedAsync(uri);

// send the text strings of the RSS feed list to an MFC output window for
// display to the user.
for (winrt::Windows::Web::Syndication::SyndicationItem item : feed.Items())
{
winrt::hstring title = item.Title().Text();
p->SendMessageToOutputWnd(WM_APP, COutputWnd::OutputBuild, (LPARAM)title.c_str());  // print a string to an output window in the output pane.
}
}
1

Другие решения

Других решений пока нет …