Windows apps
Collapse the table of content
Expand the table of content
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.
We recommend using Visual Studio 2017

Message Passing Functions


The new home for Visual Studio documentation is Visual Studio 2017 Documentation on

The Asynchronous Agents Library provides several functions that let you pass messages among components.

These message-passing functions are used with the various message-block types. For more information about the message-block types that are defined by the Concurrency Runtime, see Asynchronous Message Blocks.

This topic describes the following message-passing functions:

The concurrency::send function sends a message to the specified target synchronously and the concurrency::asend function sends a message to the specified target asynchronously. Both the send and asend functions wait until the target indicates that it will eventually accept or decline the message.

The send function waits until the target accepts or declines the message before it returns. The send function returns true if the message was delivered and false otherwise. Because the send function works synchronously, the send function waits for the target to receive the message before it returns.

Conversely, the asend function does not wait for the target to accept or decline the message before it returns. Instead, the asend function returns true if the target accepts the message and will eventually take it. Otherwise, asend returns false to indicate that the target either declined the message or postponed the decision about whether to take the message.


The concurrency::receive and concurrency::try_receive functions read data from a given source. The receive function waits for data to become available, whereas the try_receive function returns immediately.

Use the receive function when you must have the data to continue. Use the try_receive function if you must not block the current context or you do not have to have the data to continue.


For examples that use the send and asend, and receive functions, see the following topics:


Asynchronous Agents Library
Asynchronous Message Blocks
send Function
asend Function
receive Function
try_receive Function

© 2018 Microsoft