Saturday, December 7, 2013

How to achieve a similar mechanism in MFC message on iphone?

How to achieve a similar mechanism MFC messages on the iphone? For example, in other threads like MFC PostMessage to the main interface in the same thread?
Reply:
MFC not know

But can send notifications ways. That is listening

@ Interface NSNotificationCenter

There is a method to set the monitor (the main thread to define a listener)

For example - (void) postNotification: (NSNotification *) notification

Then inside the method, do what you want to do.
This is not to say I do not know. . . .

If you want to pop-up boxes, usually UIAlterview to it.
Reply:
With NSNotificationCenter message seems to be blocked? I think in my thread, finished message is returned immediately, and the rest of the victim thread ourselves.
Reply:
Sending the message to return immediately, immediately return to the main thread, or jump to the other thread to go inside?

In general, data processing threads are loaded with this one. As long as the use of the controls (page) statement, should be in the main thread to complete

If the monitor does not work well, it will use a callback. . . .

[Self perform: @ selector () withobject: (/ / execute a method parameter) other: (/ / callback function)]

Bad with listening, use the callback function :)
The callback function is relatively good control, blocking does not occur.

If you are more threads, it is recommended to use the callback function. . . Concise and easy to understand. If the page is to achieve a simple function, use the listener forget.
Reply:
I have a thread dedicated to network communication module for receiving data packets sent to the network, after receiving the package, the contents of the bag after the solution out, the results are returned to the main UI thread.
Reply:
http if the proposed use ASIHTTPRequest library, greatly improving efficiency
Reply:
Not HTTP, the client
own CS structureLooks like NSNotificationQueue can achieve this asynchronous message mechanism. .
Reply:
The reply was deleted at 2012-04-20 10:36:14 moderator

No comments:

Post a Comment