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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T18:11:17+00:00 2026-05-30T18:11:17+00:00

Since the Windows 8 consumer preview was released a few days ago, I am

  • 0

Since the Windows 8 consumer preview was released a few days ago, I am working on the new WinRT (for Metro Applications) in C# and I had ported my self written IRC class to the new threading and networking.

The problem is: My class is running an thread for receiving messages from the server. If this happens, the thread is making some parsing and then firing an event to inform the application about this. The subscribed function then ‘should’ update the UI (an textblock).

This is the problem, the thread cannot update the UI and the invoker method that has worked with .NET 4.0 doesn’t seem to be possible anymore. Is there an new workaround for this or even an better way to update the UI ? If I try to update the UI from the event subscriber i will get this Exception:

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

  • 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-05-30T18:11:18+00:00Added an answer on May 30, 2026 at 6:11 pm

    The preferred way to deal with this in WinRT (and C# 5 in general) is to use async–await:

    private async void Button_Click(object sender, RoutedEventArgs e)
    {
        string text = await Task.Run(() => Compute());
        this.TextBlock.Text = text;
    }
    

    Here, the Compute() method will run on a background thread and when it finishes, the rest of the method will execute on the UI thread. In the meantime, the UI thread is free to do whatever it needs (like processing other events).

    But if you don’t want to or can’t use async, you can use Dispatcher, in a similar (although different) way as in WPF:

    private void Button_Click(object sender, RoutedEventArgs e)
    {
        Task.Run(() => Compute());
    }
    
    private void Compute()
    {
        // perform computation here
    
        Dispatcher.Invoke(CoreDispatcherPriority.Normal, ShowText, this, resultString);
    }
    
    private void ShowText(object sender, InvokedHandlerArgs e)
    {
        this.TextBlock.Text = (string)e.Context;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Since a few days ago, MySQL server on my Windows machine was not successful
since Windows Vista there is an new Win32-API call CreateSymbolicLink to create a symbolic
I wrote a game years ago (under Windows 95) in Pascal. Since then over
Since I've read Windows User Experience Interaction Guidelines (there's a PDF download avaliable) I've
Since the WMI class Win32_OperatingSystem only includes OSArchitecture in Windows Vista, I quickly wrote
Does Windows XP (and up) store how long it has been... ...since the system
It's been a while since I've installed PHP for Windows, but every guide I've
We recently moved our Windows CE application to the SD Card. Since then the
I have been quite comfortable with windows-services, I have been practicing since from last
While developing ASP.net applications on a Windows 7 machine in Visual Studio. Sometimes I

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.