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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:44:32+00:00 2026-06-17T20:44:32+00:00

Based on the following question: General purpose FromEvent method How do I know which

  • 0

Based on the following question:
General purpose FromEvent method

How do I know which thread in my application the event will return?
I can somehow specify which thread will it continue?
What happens to the thread that is using this feature?

These responses appear to be obvious when I use WPF (Dispatcher/Main/UI Thread), but if I’m working with threads MTA, STA, Reactive, ThreadPool (Task/BackgroundWorker), how can I predict what will happen?

Is there any real benefit than using task.Wait() (if I do not have to worry about locking 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-06-17T20:44:33+00:00Added an answer on June 17, 2026 at 8:44 pm

    How do I know which thread in my application the event will return?

    You don’t. You never do with events, unless the documentation for a specific event specifies the that it will be executed from the UI thread, a thread pool thread, etc.

    I can somehow specify which thread will it continue?

    If you want to run code in a UI thread then marshal to the UI thread in the event handler. If you want to run code in a thread pool thread then add a new task to the thread pool inside of the handler. Both of those tasks add overhead if not needed, so it’s usually best to look at the documentation of the event to see which is needed.

    However, in the case of the linked question, the whole idea is that you’re no longer dealing with an event and an event handler, you’re dealing with a Task. So if you add a continuation to the task, the question is where will that continuation run? That is entirely specified by you. You can use the default task scheduler and have it run in the thread pool, you can pass a UI SynchronizationContext to run in the UI thread, or you can just let it run wherever the task you are continuing runs. (Meaning you have no idea what thread will be running it.)

    If you’re using the task with await, then it will automatically configure the continuation to run in the synchronization context you were in before you started that async operation, which may or may not be the UI thread (but likely is). If you specifically don’t want that, then use .ConfigureAwait(false);.

    Is there any real benefit than using task.Wait() (if I do not have to worry about locking thread)?

    The reason to use an asynchronous task based approach is that you’re not blocking threads, particularly thread pool threads (since you’ve specifically said you’re not blocking a UI, which is much worse). Having a thread sitting around doing nothing is a problem, in some environments more than others (such as ASP for a highly active site). By not doing a blocking wait, you aren’t consuming those resources.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Based on the following question: Check if one string is a rotation of other
For the following question, I am looking for an answer that is based on
My question is concerning SQL connection status, load, etc. based on the following code:
Now following my series of python newbie questions and based on another question .
Based on the following example URL structure: mysite.com/mypage.aspx?a=red&b=green&c=blue Pages in the application use ASP.net
This is a general DB design question. Assume the following table: ====================================================================== | product_translation_id
Yet another scenario, based on a previous question. In my opinion, its conclusion will
Following up on a previous question, here is my general class structure.. Combine Elements
I have a corpus of token-index based documents which offers a query method. The
General Python Question I'm importing a Python library (call it animals.py) with the following

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.