locked
Consume WinJS.Promise (or equivalent) in C++ code

    Question

  • I'm writing and a hybrid application in JavaScript/HTML5 for UI and C++ for backend processing. At one point I need to generate a user prompt from the C++ code and have it wait for user response.

    When initializing my C++ object I pass a JavaScript callback function that takes prompt parameters and returns a WinJS.Promise that is fulfilled when the user responds. However call to that function fails in C++ with exception 0x800A000D (type mistmatch).

    I assume that it is related to me trying to return a promise.

    I've tried these function signatures and both don't work

    IAsyncOperation<int>^ promptCallbackType(Platform::String^ text);

    Platform::Object^ promptCallbackType(Platform::String^ text);

    What is the proper way for passing a WinJS.Promise or something functionally equivalent to C++ code?

    Tuesday, October 16, 2012 7:21 PM

Answers

  • Hi,

    As far as I know, the JavaScript cannot write component, so that we cannot use JS function directly.

    But if we want to call JS function, we can use create a event in C++ and then add listen a function for this event. Fire this event in C++, so that the listener will be called in JS.
     
    Best regards,
    Jesse


    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us

    • Proposed as answer by Chris Guzak Thursday, October 18, 2012 6:24 AM
    • Marked as answer by Jesse Jiang Tuesday, October 23, 2012 2:52 AM
    Thursday, October 18, 2012 5:36 AM

All replies