How to get the dispatcher on the JavaScript side RRS feed

  • Question

  • Hello

    How can I get the UI thread dispatcher in my JavaScript app to pass down to a c# WRC?



    Tuesday, April 15, 2014 10:55 PM


All replies

  • See http://msdn.microsoft.com/en-us/library/windows/apps/dn169426.aspx for several options.

    Typically the best solution is to get it from CoreDispatcher from within the component

    Tuesday, April 15, 2014 11:24 PM
  • Hi Rob,I am trying to create a bitMapImage on the component side, but I always get an error :

    The application called an interface that was marshalled for a different thread. (Exception from HRESULT: 0x8001010E (RPC_E_WRONG_THREAD))

    even if I call with the CoreDispatcher, the problem persists.

    how can I fix it ?

    Wednesday, April 16, 2014 3:13 PM
  • Hello

    I'm trying to create a BitmapImage from a Window Runtime Component in C# called from a JavaScript app.  Tried all the examples using UI dispatcher but with no luck.  Tried to get the UI dispatcher in the JavaScript to pass to the WRC, but can't find any good examples.  Tried to use WriteableBitmapEx but having the same problem.  Thanks for any help.


    Wednesday, April 16, 2014 3:22 PM
  • occorom12

    Jump on if it gets an answer.  This is the reason I originally asked the question.  I can't get a new BitMapImage from my C# WRC.  I've tried all the examples an and WriteableBitmapEx but the same problem.


    Wednesday, April 16, 2014 3:32 PM
  • I suspect the problem is trying to use Xaml code in an HTML context. The BitmapImage likely needs a Xaml rendering thread, which your HTML app won't have. Even if you can create a BitmapImage you won't be able to render it.

    Why are you trying to create a BitmapImage in an HTML app? What is the goal here?

    From HTML you'll have better editing capabilities in the Canvas API. For low level editing you can use Direct2D.


    Wednesday, April 16, 2014 3:49 PM
  • Rob

    I think your right.  I think it's some of my problems.  I'm trying to convert a 64 byte string to an image so I can modify it.  Is there another way to make the image?  Is there a way to make an Xaml thread in my HTML JavaScript app?



    Wednesday, April 16, 2014 4:13 PM
  • For my case,  I am using a windows Runtime component in c# to use in javascript.
    This component will launch the camera and take a photo to stream (unavailbale in Js) and create a writableBitmap in order to apply the ZXing library and read a bar code.

    I have the same problem if I try to save a taken picture in c#.

    Thursday, April 17, 2014 7:55 AM
  • Well back to this.  Can I get some direction on on generating a dispatcher in a straight HTML5 JavaScript app.  Or generate an image without a dispatcher thread from a byte array.


    Monday, April 21, 2014 9:17 PM
  • You can't use Xaml in your HTML app.

    You can load your Base64 image into an HTML Canvas for editing (see http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh465794.aspx ) and then do so directly in HTML/JavaScript.

    Alternatively you can convert the string to a buffer, load it with WIC, and edit the buffer in C++.


    Monday, April 21, 2014 10:49 PM