How do i use SwapChainPanel.CreateCoreIndependentInputSource? RRS feed

  • Question

  • Hi,

    I'm trying to use CreateCoreIndependentInputSource, to put my input on another thread, as I'm getting performance issues from reading the mouse position ( which is just madness in itself! ). I think I have copied the example code correctly ...

            private async void ProcessInputAsync()
                await ThreadPool.RunAsync(new WorkItemHandler(InputHandler), WorkItemPriority.High, WorkItemOptions.TimeSliced);
            private void InputHandler(Windows.Foundation.IAsyncAction action)
                if (action.Status == AsyncStatus.Error)
                CoreInputDeviceTypes deviceTypes = 
                    CoreInputDeviceTypes.Mouse |
                    CoreInputDeviceTypes.Pen | 
                coreInput = swapChainPanel.CreateCoreIndependentInputSource(deviceTypes);
                swapChainPanel.PointerMoved += scp_PointerMoved;
                swapChainPanel.PointerPressed += scp_PointerPressed;
                swapChainPanel.PointerReleased += scp_PointerReleased;

    But this throws an exception at

        coreInput = swapChainPanel.CreateCoreIndependentInputSource(deviceTypes);

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

    Edit : Some more information. The thread window looks like this:

    11132    0    Main Thread    Main Thread    Program.Main
    4056     3    Worker Thread  <No Name>      SceneInputCollector.StartInputThreadAsync
    11728    0    Worker Thread  <No Name>      SceneInputCollector.InputHandler
    So it looks like maybe I'm creating a third thread, while the InputSource is on the second ?

    • Edited by Gavin..Williams Tuesday, March 24, 2015 1:30 AM more info
    • Moved by Kristin Xie Tuesday, March 24, 2015 9:17 AM move to better forum
    Monday, March 23, 2015 4:22 PM


  • Since I have found the issue, I don't need to implement this independent input (for now).
    Thursday, March 26, 2015 1:56 AM

All replies

  • Hi Gavin..Williams,

    Based on your code, we are not sure what your real scenario is. Could you tell us more information about it? What's your application? Store app or windows phone?

    For windows phone forum

    Windows and Windows phone apps>Developing for Windows Phone

    For store app forum

    Windows and Windows phone apps > Building Windows Store apps with C# or VB

    Have a nice day!


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, March 24, 2015 5:44 AM
  • Hi Kristin,

    I'm rebuilding my 'light' game engine for WinRT (store app). I'm using SharpDX (DirectX 11.0/11.1) and I have my engine code in a class library. I'm consuming the engine library from another WinRT project (Windows 8.1).

    When i look at the threads window, I see that my main thread is the samples, and the failure occurs on the second thread (the dll thread). I'm new to threads, so I'm not completely sure how to read that. But i would interpret that as my XAML and swap chain are created on the main thread, and my SceneInputCollector class sets up the independent input on a second thread. All the samples (in C++) say to set it up on a second thread, so that's what I'm trying to do. And since the swapchain is in xaml, it's on the main thread.

    But even if i move the call to Create.. to the MainPage_Loaded i get the same error message, likewise if i create a thread from a thread i get the same error message.

    Edit : I actually think that it's a bug that the performance is suffering simply because I'm checking the mouse position. My application is doing almost nothing at the moment - rendering a small terrain and some dx buttons.  See this post: bug report I don't recall ever having an issue with checking mouse position, performance wise, and I have never used this IndependentSource thing before.

    Is it something peculiar about the implementation of SwapChainPanel ?

    Edit 2 (This from bug thread) : Strangely I ran my application today and there was no hitching at all when i moved the mouse. But just now, the hitching has returned. I didn't make any changes to the code. I'm investigating.... Ok, I can cause this issue to vanish as long as I'm downloading in firefox (I was downloading Windows 10). I tried downloading in steam, and it didn't prevent the hitching. But I even started downloading W10 a second time just to test it, and sure enough, the hitching in my app went away. How strange is that !

    Tuesday, March 24, 2015 7:05 AM
  • Since I have found the issue, I don't need to implement this independent input (for now).
    Thursday, March 26, 2015 1:56 AM