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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T03:43:29+00:00 2026-05-21T03:43:29+00:00

Been doing some brief research into multithreaded C# event handling because I had a

  • 0

Been doing some brief research into multithreaded C# event handling because I had a suspicion that event handlers would simply be called on whatever thread invoked an event, which turns out to be true.

Now this strikes me as a really bad idea, because the code that subscribes to an event on an object may not be designed to be multithreaded at all, and the implementation of that object (which should be a black box, no?), if multithreaded behind the scenes (as in my case) can cause the subscriber code to be executed on multiple threads, causing all sorts of weird problems.

So my question is, is it possible to push an event back to the thread that originally subscribed to it, thus avoiding any unexpected concurrency at the subscriber level? Or put more abstractly, can I record the current thread at a point in time, and push an event handler call (or any arbitrary piece of code) onto that thread at a later point in time?

The clincher is this: I’m doing this in a DLL that doesn’t reference WinForms or WPF. I know constructs exist in those frameworks to allow for this (and I’ve used them myself) but I want to do this without having to reference those libraries.

A little background:

My design uses background threads to do work on an object which can result in its properties being changed. I use INotifyPropertyChanged to signal changes to those properties to observers. I use WPF outside of the library to display these objects in interfaces, thus INotifyPropertyChanged is useful because it tells WPF to update the screen when a property has changed on the object that is being displayed.

I’m assuming WPF handles multithreaded change notifications internally, so if I stuck solely to WPF there probably wouldn’t be a problem. However, I’d like anybody to be able to subscribe to the change events and not have to worry about them being called on background threads.

  • 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-21T03:43:30+00:00Added an answer on May 21, 2026 at 3:43 am

    You can use the SynchronizationContext class to run code on a UI thread without referencing WinForms or WPF.

    Capture SyncronizationContext.Current whenever you add a handler, then use the captured instances to call each handler.

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

Sidebar

Related Questions

Recently I've been doing some research into SEO and how URIs that use hyphens
Been doing some Android permission research and ran across an application that - according
I've been doing some research into finally automating our Development builds and still have
We have been doing some research into physically isolating the secure and non-secure sections
I've been doing some research about Swing in order to build a css editor
I have been doing some research on test driven development and find it pretty
i've been doing some research on interfaces and a simple layman's explanation for what
I've been doing some research on popular Java security frameworks (Spring Security and Apache
I have been doing some research for using MSMQ. Following 2 gave me fundamental
I have been doing some research on the correct procedure to follow when working

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.