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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:12:07+00:00 2026-05-13T11:12:07+00:00

I’m writing a c# component that will only be used internally at my company.

  • 0

I’m writing a c# component that will only be used internally at my company. The component encapsulates communication with a number of servers that particular desktop applications need to communicate with. The servers can send unsolicited messages to the component, which are ‘caught’ in a separate thread.

I want the majority of this component to execute under the context of its creating thread. I do not wish the separate message thread to do any message processing. Instead, I would like to notify the main thread that there is a message awaiting processing. The reason for wanting to execute under the context of the creating thread, is that users of the library may not know multi-threading, and I’d like to be able to synchronize all operations if possible.

Is there an easy way of signaling a running thread? The main thread will be doing all kinds of constant processing, and the message thread will be constantly spinning waiting for messages. It may be worth noting that the message thread is encapsulated in a third party library. Once it receives a message, it executes a callback. I’d like the callback to do something like mainthread.notify(message).

Edit:
Sorry I wasn’t too clear on what I want the main thread to do. I don’t want the main thread to immediately process the message sent by the message thread. I want it to process the message at some time in the near future (like how the WinForms Message Loop works).

Edit 2:

The scenario:

Console App created on Thread1  
Thread2 created, which spins listening for Messages
Console App runs as normal
Message arrives on Thread2
Thread2 fires event MessageReady(sender, message)
Thread2 continues spinning
At the earliest convenience, Thread1 processes the message from MessageReady

I’ve done some reading, and it appears that marshaling code to another thread is quite a difficult manner, and I’m doubting that synchronizing this process would be worth the effort.

  • 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-13T11:12:07+00:00Added an answer on May 13, 2026 at 11:12 am

    No, that’s not possible. A thread has to go idle before you can inject code into it. That’s done by, for example, Control.BeginInvoke (Windows Forms) or Dispatcher.BeginInvoke (WPF). These UI libraries often require code to be executed on the UI thread so they have explicit support for marshaling calls to the UI thread.

    It is important for a thread to be in an “idle” state. You would have horrible re-entrancy problems if .NET supported some kind of asynchronous injection method.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
I am doing a simple coin flipping experiment for class that involves flipping a

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.