Quantcast
Viewing all articles
Browse latest Browse all 4845

New Post: Exception on Wait()

Hi,

I am having an issue with using wait, get etc. Basically anything that makes an Async call sync.

I have a windows mobile 8.1 project in C#. We are using C++ for common functionality across platform (android, win8.1 and IOS). In Win8.1 we are using a Windows component run time project for the C++.

I can call my service access Async fine. Seems to work. As soon as i go method().wait() i get a invalid parameter error.

pplx::task<void> RestF::HTTPGetAsyncTST()
{
// I want to make the following HTTP GET: http://api.flickr.com/services/rest/?method=flickr.test.echo&name=value
http_client client(U("http://api.flickr.com/services/rest/"));

uri_builder builder;
// Append the query parameters: ?method=flickr.test.echo&name=value
builder.append_query(U("method"), U("flickr.test.echo"));
builder.append_query(U("name"), U("value"));

auto path_query_fragment = builder.to_string();

// Make an HTTP GET request and asynchronously process the response
return client.request(methods::GET, path_query_fragment).then([](http_response response)
{
    // Display the status code that the server returned
    std::wostringstream stream;
    stream << L"Server returned returned status code " << response.status_code() << L'.' << std::endl;
    std::wcout << stream.str();

    stream.str(std::wstring());
    stream << L"Content type: " << response.headers().content_type() << std::endl;
    stream << L"Content length: " << response.headers().content_length() << L"bytes" << std::endl;
    std::wcout << stream.str();

    auto bodyStream = response.body();
    streams::stringstreambuf sbuffer;
    auto& target = sbuffer.collection();

    bodyStream.read_to_end(sbuffer).get();

    stream.str(std::wstring());
    stream << L"Response body: " << target.c_str();
    std::wcout << stream.str();
});
}

RestF::RestF()
{
// THIS LINE GETS EXCEPTION!
HTTPGetAsyncTST().wait();
}

Any help would be greatly appreciated.
Kind regards,

Viewing all articles
Browse latest Browse all 4845

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>