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

  • Home
  • SEARCH
  • 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 8334573
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T03:23:51+00:00 2026-06-09T03:23:51+00:00

I have a class that exposes a public Event. There are various controls on

  • 0

I have a class that exposes a public Event. There are various controls on the GUI that can register their event handlers with this Event to make changes to the controls such as text or back color etc. However, the class that exposes the Event does not keep any references of the UI controls those may have added their event handlers.

During the execution, a separate foreground thread executes a method that will invoke (fire) the public Event. This calls the event handlers that have registered with the event.

The problem is that the event handlers are called on the foreground thread and not on UI thread. How do I marshall the call to the UI thread without the reference of the UI controls?

  • 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-09T03:23:52+00:00Added an answer on June 9, 2026 at 3:23 am

    You need to decide what’s going to do the marshalling: the event raiser, or the event handlers. If you don’t want the event raiser to know anything about threading – e.g. via ISynchronizeInvoke or SynchronizationContext – then make the event handlers do the marshalling instead.

    Basically either the event raiser should guarantee that it will raise all events in a particular context (which could be given to it on construction via SynchronizationContext) or it should make it clear that it’s not doing so, and put the onus on the handlers. The latter is the more flexible approach – it means that if you have several handlers with different needs, each can do the appropriate thing for its own needs.

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

Sidebar

Related Questions

Assume that I have a class that exposes the following event: public event EventHandler
I have class that looks like this: class A { public: class variables_map vm
I have a static class, which exposes a event: public static class MyStaticClass {
I have a class that exposes an auto implemented property Enabled Public MustInherit Class
I have this class that exposes an IEnumerable<Record> as follows (implementation details left out):
I have a data object -- a custom class called Notification -- that exposes
I have a Class that has a private variable with a public setter/getter function:
Why does C++ have public members that anyone can call and friend declarations that
I have a templated C++ class that exposes a number of methods, e.g template<int
Any efficient/reliable way to expose one event? I have a class, MultipleDocumentCopier that copies

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.