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

  • SEARCH
  • Home
  • 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 8928879
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:32:54+00:00 2026-06-15T08:32:54+00:00

I have create a metro app which is composed by – a c# windows

  • 0

I have create a metro app which is composed by
– a c# windows runtime component
– a javascript application, wich contains the UI and is the main application.

In the c# component I created an async method:

async public void createDocument() {
}

but when I try to call it from the javascript code, I cannot use the .done() or the then() function to handle the method completed evet, because there is an error: javascript error, cannot call done() from object not set to an instance of object.

If I try to assign Task or Task to the function I have another error, which tell me Task is not a windows runtime type and to use IAsyncOperation, IAsyncAction, ecc.. instead.

So, how can I create an async function in the c# windows runtime component and call it from javascript handling the done() or then() events?

  • 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-15T08:32:55+00:00Added an answer on June 15, 2026 at 8:32 am

    I found an article that seems to be related to the problem you are having. I haven’t done this myself, but the gist of it says that you can’t use the async keyword from C# for Javascript promises – you must wrap the method in a slightly different way:

    instead of:

    public sealed class Class1
    {
        public async void testAsync()
        {
            // do this asynchronously ...
        }
    }
    

    try:

    public sealed class Class1
        {
            public IAsyncActionWithProgress<Result> testAsync()
            {
                return AsyncInfo.Run<Result>((token, result) =>
                    Task.Run<Result>(()=>
                        {
                            // do this asynchronously ...
                            return new Result();
                        }
    
                    ));
            }
        }
    
        public sealed class Result { ... }
        }
    

    I copied and pasted the examples from this article by Ronald Widha – http://www.ronaldwidha.net/2012/05/10/winrt-consumer-preview-calling-c-csharp-async-class-libraries-from-javascript-winjs-promises-using-then-clause/ It was written during the consumer preview, so it might have changed between then and the final release

    Hopefully that will help you a bit more!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm building a Windows 8 Metro app in HTML5/Javascript, and I have several screens
I have a Windows 8 Metro application created from the Grid Application template. I
I intended to create a Windows 8 Style App (Metro), but found out there
I'm trying to create some primitive imitation of the Windows Metro style application. What
I have a Windows 8 Metro app created in XAML, C# from the template.
I want to create Metro apps for Windows 8, and I have VS 2012,
I'm attempting to create an application that looks much like the Windows 8 Metro
I have create a simple application which using C++ and produce a executable file.
I have created metro style Grid Application which preview data that i get it
I am trying to create a metro app based on a Developing windows 8

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.