Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8967665
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:17:44+00:00 2026-06-15T17:17:44+00:00

I am having a crash course on WinRT IAsyncOperation, async, await. I am trying

  • 0

I am having a crash course on WinRT IAsyncOperation, async, await. I am trying to wrap Task with IAsyncOperation but fail to come up with an easy way to do the casting.

public interface IInfo{}
public class InfoList : IInfo{}

public class Parser {
    private async Task<InfoList> ParseList() {
        var returnList = new InfoList();

        HttpClient client = new HttpClient();
        Task<string> htmlTask = client.GetStringAsync("http://stackoverflow.com");

        string html = await htmlTask;
        // parsing logic...
        return returnList;
    }

    public IAsyncOperation<IInfo> Parse()
    {
        return AsyncInfo.Run(_ =>
            Task.Run<IInfo>(async () =>
            {
                var returnList = await ParseList();
                return returnList;
            })
        );
        // I have tried following but causes InvalidCastException
        //return (IAsyncOperation<IInfo>)ParseList().AsAsyncOperation<InfoList>();
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T17:17:45+00:00Added an answer on June 15, 2026 at 5:17 pm
    public IAsyncOperation<IInfo> Parse()
    {
        return AsyncInfo.Run(async _ => (IInfo) await ParseList());
    }
    

    or

    public IAsyncOperation<IInfo> Parse()
    {
        return AsyncInfo.Run(_ => ParseList().ContinueWith(t => (IInfo)t.Result));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having this log (of course with the crash of my activity :D )
I'm having crash in my application, which says trying to pop an unknown autorelease
Is there a way to do this in C++ without having things crash on
I'm having this crash now and then, in a thread that is not started
Got a crash report from a beta tester and I'm having trouble identifying the
Im having a problem with my app that causes it to crash when no
Having trouble with an .htaccess file on WAMP. Works on the live server, but
I'm using a combination of SDL and OpenGL in a sort of crash course
I am having a crash issue while playing video in iphone 4.0 OS. Actually,
A user of my app out in the field seems to having bad crash-at-app-start

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.