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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:16:11+00:00 2026-06-17T19:16:11+00:00

The following question is about the unity game engine, but it could relate to

  • 0

The following question is about the unity game engine, but it could relate to any program trying to send data to a main thread, such as the UI thread.

I am processing some data on a separate thread (position data a read asyncrously from a socket). However, I need to act on this data on the main thread (a game object’s transform can only be accessed from the main thread). The approach I have in mind is to create a thread-safe queue and follow the producer-consumer pattern. The thread would queue the position data and the main thread would deque the data and act on it. *Note: In Unity I do not have access to the System.Windows.Threading name space so I can not use Dispatcher. Also, it requires .Net 3.5 so I can’t use the Collections.Concurrent name space either.

Is there a better approach?

If there isn’t, what is the best way to inform the main thread when data is queued? It seems inefficient to poll, but I can’t think of any way around it..

Thanks in advance.

  • 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-17T19:16:12+00:00Added an answer on June 17, 2026 at 7:16 pm

    That is a totally viable approach to threading. As you probably know, the alternative to polling found in computer hardware is the concept of interrupts.

    How would you simulate interrupts in a multithreaded high-level computer program? Hard to say – your thread that changes would have to notify the UI thread “hey I’m ready”, rather than the UI thread checking constantly. This requires some sort of message passing, really – it may not be feasible.

    That being said, the typical game-design approach is the “game loop” that does, essentially, poll. So there is no shame in that game – you just have to make sure it doesn’t murder your performance.

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

Sidebar

Related Questions

I thought about the following question about computer's architecture. Suppose I do in Python
I have the following question about JPA: Can I save the order of the
Following a question posted here about how I can increase the speed on one
Following on from my earlier question about creating Address Books (many thanks Peter!), I
I have a question about the following regular expression: I want to match the
I have a question about the following code in TCL/EXPECT: expect { timeout {
I have a question about the following C code: void my_function() { int i1;
I have a question about the following code : #include <iostream> #include <ctime> int
I got asked the following question in an interview while talking about concurrency in
I have a question about how GC works in Java. Consider the following code:

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.