Tag Archives: TDD

TDD in WinRT

While experimenting with TDD I run into a pretty nasty exception:

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

However after some investigation I found a very good solution here.

public async Task Test1()
      await ExecuteOnUIThread(() =>
           WriteableBitmap bitmap = new WriteableBitmap(1, 1);

public IAsyncAction ExecuteOnUIThread(DispatchedHandler action)
     return CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, action);

Happy coding!