PostMessage/SendMessage* operations can fail due to a number of reasons, such as invalid address, impossibility to connect to destination or some other reason. The error can happen before the message is passed to transport for delivery or after that.
When the message delivery fails before the message is passed to transport, an exception is raised. When the message delivery fails after that, before CBFS IPC 1.3 there was no way to get to know about error or timeout.
In CBFS IPC the application is notified about error in two ways:
- Using exception, when you use any of PostMessage/SendMessage* methods. Note, that if error happens after the call to SendMessageCallback or SendMessageTimeoutCallback, exception is not raised (of course).
- Using callback when you use SendMessageTimeoutCallback method.
The application is notified about timeout in several ways:
In other words, to properly handle all error and timeout situations, it is necessary to use either SendMessageTimeout or SendMessageTimeoutCallback methods.
- Using exception in SendMessage method
- By returning false in SendMessageTimeout method
- Using OnTimeout callback when you use SendMessageTimeoutCallback method