Message

A message can by any .NET object. The message contains only information, no logic. Messages are sent asynchronously using message channel. After creating the message its data should not change anymore. Therefore storing service references or global application variables in the message should be avoided.

If the message is a result of an asynchronous operation, you can derive your custom message from the AsyncOperationResponseMessage.

    public class AsyncOperationResponseMessage
    {
        public AsyncOperationResponseMessage() {...}
        public AsyncOperationResponseMessage(Exception error) {...}
        public AsyncOperationResponseMessage(Exception error, bool cancelled) {...}

        public Exception Error {...}
        public bool HasError {...}
        public bool Cancelled {...}
    }
It's recommended to name messages by adding the suffix RequestMessage or ResponseMessage (eg. DoJobRequestMessage, DoJobResponseMessage). However sometimes it's necessary to create messages out of this pattern (eg. MyPropertyChangedMessage, InitializationCompletedMessage).

Last edited Jan 13, 2013 at 7:44 AM by polo, version 3

Comments

No comments yet.