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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T13:39:17+00:00 2026-05-13T13:39:17+00:00

On windows, each thread has a message queue, and each message queue will process

  • 0

On windows, each thread has a message queue, and each message queue will process messages for the windows owned by that thread.
This means that it is quite simple to write an application where you can create a thread, with a message loop, and one (or more) windows. Ignoring any kind of application issues, one now has application windows that will keep on interacting with the user even if one of the other windows is busy in some kind of modal operation.

Now, in porting the app to cocoa, I encounter, well, Interface Builder. Which is a surprise to someone who expects to be more in control of window creation and message loop construction. None the less I can see where IB is coming from.

My problem however, lies with the opaque funciton NSApplicationMain(). This – on the applications main thread, automatically creates the applications main window, and runs the message pump, all data driven nicely from the NIB files.

However, this leaves me with a problem: Even if I buy into the idea that Interface Builder is the way to go for making my main app window – and I have figured out enough objective C to create sub windows on the fly – as well as how to create threads – I can’s see how to create a message pump in worker threads. I begin to doubt its possible.

Do windows in cocoa even have the kind of thread affinity they do In Win32? i.e. each thread has its own message dispatching loop for windows owned by that thread? Im beginning to suspect that perhaps Cocoa expects all my windows to be ‘owned’ by the main thread and I just get to offset work (and drawing) onto other threads.

Any clues as to how best to translate a multi window-per-thread Win32 app to Cocoa’s paradigms?

  • 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-13T13:39:17+00:00Added an answer on May 13, 2026 at 1:39 pm

    Interface Builder is a red herring in this discussion. The real question is centric to the design patterns of Cocoa and these two paragraphs from your question are key:

    However, this leaves me with a
    problem: Even if I buy into the idea
    that Interface Builder is the way to
    go for making my main app window – and
    I have figured out enough objective C
    to create sub windows on the fly – as
    well as how to create threads – I
    can’s see how to create a message pump
    in worker threads. I begin to doubt
    its possible.

    Do windows in cocoa even have the kind
    of thread affinity they do In Win32?
    i.e. each thread has its own message
    dispatching loop for windows owned by
    that thread? Im beginning to suspect
    that perhaps Cocoa expects all my
    windows to be ‘owned’ by the main
    thread and I just get to offset work
    (and drawing) onto other threads.

    In short, no, it doesn’t work like that. Cocoa has a completely different event handling model and a completely different set of tools for supporting Concurrency.

    Notably, Cocoa has a strong notion of a main event loop that runs always on the main thread. This is where user events are handled and where almost all drawing occurs (though this restriction has been loosened over time).

    It is different and trying to bend it to work like the thread-per-window-with-pump is a path of extreme pain. Don’t go down it.

    Now, Cocoa does have run loops per thread. But they are not used to process user events.

    In short, you are going to need to revisit the architecture of your application to pull the code over to Cocoa. A straight port isn’t possible.

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

Sidebar

Ask A Question

Stats

  • Questions 445k
  • Answers 445k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Ok, I'm assuming you're using PHP and MySQL... You have… May 15, 2026 at 6:50 pm
  • Editorial Team
    Editorial Team added an answer Ugly hack alert: create 2 versions of your text, one… May 15, 2026 at 6:50 pm
  • Editorial Team
    Editorial Team added an answer partitioned functions introduced in SQL 2005 don't support this AFAIK… May 15, 2026 at 6:50 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.