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 7822951
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T08:04:50+00:00 2026-06-02T08:04:50+00:00

I posted a question some time ago on MSDN forum involving the following code.

  • 0

I posted a question some time ago on MSDN forum involving the following code. It creates on a new thread, reads thumbnail from a file and displays it through Dispatcher.

private void Button_Click_1(object sender, RoutedEventArgs e)
    {
        Task.Factory.StartNew(async()=>{
            var localFolder = Windows.Storage.ApplicationData.Current.LocalFolder; ;

            var file = await localFolder.CreateFileAsync(".txt", Windows.Storage.CreationCollisionOption.OpenIfExists);
            var t = await file.GetThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode.DocumentsView);
            //Some proccessing....
            this.Dispatcher.Invoke(Windows.UI.Core.CoreDispatcherPriority.Normal,(a,b)=>{
                var bmp = new BitmapImage();
                bmp.SetSource(t); //Exception here
                image.Source = bmp;
            }, this, null);
            //Some more stuff...
        });
    }

image is just an Image control in the XAML

I get a big exception if above code executes. The exception occurs at bmp.SetSource(t).

Here is full exception info:

Transition into COM context 0x1347668 for this RuntimeCallableWrapper
failed with the following error: An outgoing call cannot be made since
the application is dispatching an input-synchronous call. (Exception
from HRESULT: 0x8001010D (RPC_E_CANTCALLOUT_ININPUTSYNCCALL)). This is
typically because the COM context 0x1347668 where this
RuntimeCallableWrapper was created has been disconnected or it is busy
doing something else and cannot process the context transition. No
proxy will be used to service the request on the COM component and
calls will be made to the COM component directly. This may cause
corruption or data loss. To avoid this problem, please ensure that all
COM contexts/apartments/threads stay alive and are available for
context transition, until the application is completely done with the
RuntimeCallableWrappers that represents COM components that live
inside them.

Switching from using Invoke to InvokeAsync fixes the problem, but I’m wondering why. Can someone explain?

EDIT: Above is just some test code. The Task I created is meant to simulate execution under a non-UI thread context which occurs in my app since it need to both read files and update UI from a none-UI thread context.

  • 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-02T08:04:52+00:00Added an answer on June 2, 2026 at 8:04 am

    I can’t understand the reason for the Task inside the click handler given that you just end up invoking it on UI thread anyway.

    private void Button_Click_1(object sender, RoutedEventArgs e)
    {
      var localFolder = Windows.Storage.ApplicationData.Current.LocalFolder;
      var file = await localFolder.CreateFileAsync(".txt", Windows.Storage.CreationCollisionOption.OpenIfExists);
      var t = await file.GetThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode.DocumentsView);
      var bmp = new BitmapImage();
      bmp.SetSource(t); //Exception here
      image.Source = bmp;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Some time ago i posted a question related to a WriteableBitmap memory leak, and
Some time ago I posted a question about what questions should a good javascript
I have posted similar question previously, but this time I am providing some code
I posted some days ago this question: How to intersect multiple polygons? . Now
In my last question I posted some sample code on how I was trying
A short time ago, this function was posted in an answer to a question.
This question was posted on some site. I didnt find right answers there, so
So this morning I posted a confused question about assembly and I received some
Following a question posted here about how I can increase the speed on one
Sometime ago the question Ms-RL - Explanation needed was posted. The only answer given

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.