1 Sender: wxstorm (Penguin), email area: VisualC
Question: sendmessage
Mailing station: shuimu community (Mon Jan 24 21:32:25 2011), within the station
On msdn, after sendmessage sends a message to a form in another thread, it is directly sent to its message processing function, which will not be returned until the message is processed.
In which thread is the message processing function executed?
Is the thread that calls sendmessage or the thread where the form is located?
-- 2 Sender: cavalho (difference: R ...), Email: VisualC
Question: Re: sendmessage
Mailing station: shuimu community (Mon Jan 24 21:40:36 2011), within the station
Of course, the thread where the form is located
[Mentioned in the wxstorm (Penguin) masterpiece :]
: In msdn, after sendmessage sends a message to a form in another thread, it is directly sent to its message processing function, which will not be returned until the message is processed.
: In which thread is the message processing function executed?
: Is the thread that calls sendmessage or the thread where the form is located?
: .......... 3 Sender: zjudm (Qiantang guanchao), email area: VisualC
Question: Re: sendmessage
Mailing station: shuimu community (Mon Jan 24 21:42:15 2011), within the station
No special things. Use post.
[Mentioned in the wxstorm (Penguin) masterpiece :]
: In msdn, after sendmessage sends a message to a form in another thread, it is directly sent to its message processing function, which will not be returned until the message is processed.
: In which thread is the message processing function executed?
: Is the thread that calls sendmessage or the thread where the form is located?
:...................
--
4 Sender: solosure (roworsure), email area: VisualC
Question: Re: sendmessage
Mailing station: shuimu community (Mon Jan 24 21:42:57 2011), within the station
If the specified window was created by the calling thread, the window procedure is called immediately as a subroutine. if the specified window was created by a different thread, the system switches to that thread and callthe appropriate window procedure.
This sentence is also in msdn.
[Mentioned in the wxstorm (Penguin) masterpiece :]
: In msdn, after sendmessage sends a message to a form in another thread, it is directly sent to its message processing function, which will not be returned until the message is processed.
: In which thread is the message processing function executed?
: Is the thread that calls sendmessage or the thread where the form is located?
--
5 Sender: wxstorm (Penguin), email area: VisualC
Question: Re: sendmessage
Mailing station: shuimu community (Mon Jan 24 21:44:30 2011), within the station
In the thread where the form is located, how is this thread suddenly interrupted to execute this message processing function? Directly interrupted the current execution point and jumped to the message processing function?
In addition, how does the sendmessage thread know that the function of the thread has been executed?
[In cavalho (a difference of R ...) As mentioned in the masterpiece :]
: Of course, the thread where the form is located
-- 6 Sender: zjudm (Qiantang guanchao), email area: VisualC
Question: Re: sendmessage
Mailing station: shuimu community (Mon Jan 24 21:46:39 2011), within the station
The message is a red bean and is distributed by the queue.
[Mentioned in the wxstorm (Penguin) masterpiece :]
: In the thread where the form is located, how is this thread suddenly interrupted to execute this message processing function? Directly interrupted the current execution point and jumped to the message processing function?
: How does the sendmessage thread know that the function of the thread has been executed?
-- 7 Sender: wxstorm (Penguin), email area: VisualC
Question: Re: sendmessage
Mailing station: shuimu community (Mon Jan 24 21:47:26 2011), within the station
Well, I have also seen this passage.
The system switches to that thread... How is this implemented?
Isn't this equivalent to inserting a paragraph in the thread's execution process?
So I don't quite understand what's going on...
[Mentioned in solosure's masterpiece :]
: If the specified window was created by the calling thread, the window procedure is called immediately as a subroutine. if the specified window was created by a different thread, the system switches to that thread and callthe appropriate Window Proc
: This sentence is also in msdn.
--
8 Sender: solosure (roworsure), email area: VisualC
Question: Re: sendmessage
Mailing station: shuimu community (Mon Jan 24 21:51:07 2011), within the station
It may be implemented by message queue.
[Mentioned in the wxstorm (Penguin) masterpiece :]
: Well, I have also seen this passage.
: The system switches to that thread... How is this implemented?
: Isn't this equivalent to a piece of plug-in the thread execution process?
:...................
--
The truth is out there.9 Sender: wxstorm (Penguin), email area: VisualC
Question: Re: sendmessage
Mailing station: shuimu community (Mon Jan 24 21:55:25 2011), within the station
No.
Nonqueued messages are sent immediately to the destination window procedure, bypassing the system message queue and thread Message Queue
Sendmessage should directly go beyond the system message queue and thread message queue...
Is there a third message queue besides the two?
[Mentioned in solosure's masterpiece :]
: It may be implemented by message queue.
-- 10 Sender: ckevin (), email area: VisualC
Question: Re: sendmessage
Mailing station: shuimu community (Mon Jan 24 23:18:12 2011), within the station
My understanding is not necessarily correct.
Send does not go beyond the message queue. If he calls the message processing process directly, how can he switch to another thread? If he immediately asks the other party to interrupt the work at hand, what should the other party do if it is doing important things or in the kernel state. I think it should be send to send the message to the queue of the other party, and then wait for the receiving process of the other party's message, such as get to get and process the message. Send and return the message. The reason why sending calls the message processing process is that only the message processing process can process the message. On the other hand, sending does not guarantee that it is always blocked, it is not guaranteed that the other party must handle the issue immediately.
[Mentioned in the wxstorm (Penguin) masterpiece :]
: No.
: Nonqueued messages are sent immediately to the destination window procedure, bypassing the system message queue and thread Message Queue
: Sendmessage should directly go beyond the system message queue and thread message queue...
:...................
--
If anyone else has any objection, let's look at the comments of the zhengself committee. They will also be moved like me.
[Mentioned in the masterpiece zhengself (or: Google lab group :]
: Actually, at least D.
I said she was at least D. It's not natural.
: No need to use YY, B or a, and no need to squeeze the water girl.
: That's why you see less photos of her .... 11 Sender: cavalho (a difference of R ...), Email: VisualC
Question: Re: sendmessage
Mailing station: shuimu community (Mon Jan 24 23:53:32 2011), within the station
This is almost the case. You can check the source code of reactos.
[Mentioned in the ckevin () masterpiece :]
: My understanding is not necessarily correct.
: Send does not go beyond the message queue. If he calls the message processing process directly, how can he switch to another thread? If he immediately asks the other party to interrupt the work at hand, what should the other party do if it is doing important things or in the kernel state. I think it should be send to send the message to the other party's queue, and then wait for the other party's message acquisition process, such as get to get and process the message, Sen
-- 12 Sender: firecloud (restarting...), email area: VisualC
Question: Re: sendmessage
Mailing station: shuimu community (Tue Jan 25 09:35:44 2011), within the station
Send: make sure the other Party handles the request immediately.
[Mentioned in the ckevin () masterpiece :]
: My understanding is not necessarily correct.
: Send does not go beyond the message queue. If he calls the message processing process directly, how can he switch to another thread? If he immediately asks the other party to interrupt the work at hand, what should the other party do if it is doing important things or in the kernel state. I think it should be send to send the message to the other party's queue, and then wait for the other party's message acquisition process, such as get to get and process the message, Sen
-- 13 Sender: xiaoju (cute dragon CAT), email area: VisualC
Question: Re: sendmessage
Mailing station: shuimu community (Tue Jan 25 10:19:23 2011), within the station
Not necessarily. In case the other party's message is blocked in a loop, it will not work.
[Mentioned in the masterpiece of firecloud (restarting :]
: Send. Make sure the other Party handles the request immediately.
-- 14 Sender: firecloud (restarting...), email area: VisualC
Question: Re: sendmessage
Mailing station: shuimu community (Tue Jan 25 10:22:55 2011), within the station
In this case, sendmessage itself will also block
[Mentioned in xiaoju's masterpiece :]
: Not necessarily. In case the other party's message is blocked in a loop, it will not work.
-- 15 Sender: solosure (roworsure), email area: VisualC
Question: Re: sendmessage
Mailing station: shuimu community (Tue Jan 25 12:56:07 2011), within the station
Messages sent between threads are processed only when the processing ing thread executes message retrieval code. The sending thread is blocked until the processing thread processes the message.
This is the next sentence, which is also in msdn.
[Mentioned in the wxstorm (Penguin) masterpiece :]
: No.
: Nonqueued messages are sent immediately to the destination window procedure, bypassing the system message queue and thread Message Queue
: Sendmessage should directly go beyond the system message queue and thread message queue...
:...................
--
The truth is out there.16 Sender: wxstorm (Penguin), email area: VisualC
Question: Re: sendmessage
Mailing station: shuimu community (Tue Jan 25 16:23:30 2011), within the station
Well, this is indeed the case. Thank you!
You can see it when reading getmessage and peekmessage. In msdn:
During this call, the system delivers pending messages that were sent to Windows owned by the calling thread using the sendmessage, sendmessagecallback, sendmessagetimeout, or sendpolicymessage function. the system may also process internal events. messages are processed in the following order:
Sent messages
Posted messages
Input (hardware) messages and system internal events
Sent messages (again)
Wm_paint messages
Wm_timer messages
Well, I understand that getmessage and peekmessage have done all the work. If it is sent messages, getmessage is equivalent to dispatchmessage, and all the sent messages have been processed, to check the queue message.
So if the sent messages has no window, it is equivalent to nothing and does not work, that is, the thread message can only be post, so there are two functions postmessage and postthreadmessage, but only sendmessage, there is no corresponding sendthreadmessage ..
[Mentioned in the ckevin () masterpiece :]
: My understanding is not necessarily correct.
: Send does not go beyond the message queue. If he calls the message processing process directly, how can he switch to another thread? If he immediately asks the other party to interrupt the work at hand, what should the other party do if it is doing important things or in the kernel state. I think it should be send to send the message to the other party's queue, and then wait for the other party's message acquisition process, such as get to get and process the message, Sen
--
17 Sender: wxstorm (Penguin), email area: VisualC
Question: Re: sendmessage
Mailing station: shuimu community (Tue Jan 25 16:24:35 2011), within the station
Well. Message retrieval code should be getmessage/peekmessage.
Thank you.
[Mentioned in solosure's masterpiece :]
: Messages sent between threads are processed only when the processing ing thread executes message retrieval code. The sending thread is blocked until the processing thread processes the message.
: This is the next sentence, which is also in msdn.
-- 18 Sender: FIU (⊙ o ⊙), email area: VisualC
Question: Re: sendmessage
Mailing station: shuimu community (Wed Jan 26 10:29:19 2011), within the station
My understanding: Not necessarily true.
1. When to execute sendmessage and postmessage, how to execute it should be considered from the multi-thread perspective.
The sendm is synchronous. if the message is sent, it must wait for the response from thread a to continue. Postm sends directly
The message queue of the other thread B is returned asynchronously.
When is synchronization and Asynchronization executed? I feel like I should also check when the time slice is round-robin to the corresponding thread.
2. I am also confused about English. I think it is appropriate to post wxstorm in English. Sendm sends messages directly and calls
The wndproc of the message should be the nonqueued message, and the postm is plugged into the queue,
In fact, how do I feel that there is not much time difference between nonqueued message and queued message,
The thread is executed, and both of them are completed soon. If no sendm is executed, the Group must be congested.
The difference between the two is the difference between synchronization and synchronization. CK Daniel's send does not guarantee its own blocking. Do you need to verify it :)
[Mentioned in the ckevin () masterpiece :]
My understanding is not necessarily correct.
Send does not go beyond the message queue. If he calls the message processing process directly, how can he switch to another thread? If he immediately asks the other party to interrupt the work at hand, what should the other party do if it is doing important things or in the kernel state. I think it should be send to send the message to the queue of the other party, and then wait for the receiving process of the other party's message, such as get to get and process the message. Send and return the message. The reason why sending calls the message processing process is that only the message processing process can process the message. On the other hand, sending does not guarantee that it is always blocked, it is not guaranteed that the other party must handle the issue immediately.
[Mentioned in the wxstorm (Penguin) masterpiece :]
: No.
: Nonqueued messages are sent immediately to the destination window procedure, bypassing the system message queue and thread Message Queue
: Sendmessage should directly go beyond the system message queue and thread message queue...
:...................To thoroughly solve this problem, I read the wine implementation code as follows: <br/> static lresult send_inter_thread_message (const struct send_message_info * info, lresult * res_ptr) <br/>{< br/> size_t reply_size = 0; <br/> trace ("hwnd % p msg % x (% s) WP % lx LP % LX/N ", <br/> Info-> hwnd, info-> MSG, spy_getmsgname (Info-> MSG, info-> hwnd ), info-> wparam, info-> lparam); <br/> user_checknotlock (); <br/> If (! Put_message_in_queue (Info, & reply_size) return 0; <br/>/* There's no reply to wait for on every y/callback messages */<br/> If (Info-> type = msg_policy | Info-> type = msg_callback) return 1; <br/> wait_message_reply (Info-> flags); <br/> return retrieve_reply (Info, reply_size, res_ptr); <br/>}< br/>
--