This project is read-only.

What is MCM?

MCM (Message-Command-Message) is an open source framework for building modular, military simple .NET applications and state machine APIs of any size.

How does MCM work?

The principle of MCM is a remake of the best known pattern - the nature.

Imagine a small village (your application) with some residents (components). All residents live and work independently (asynchronously). They communicate with each other directly or broadcast messages using cb radio and additionally send packets using a post-office (message channel).

The barber broadcasts a message – I need a new razor! All residents (subscribers) receive the message but only the smith can make the razor. He creates a new razor and gives it to the postman for delivery. The barber receives the razor and he can work further.

MCM (Message-Command-Message) as a village example

The village above is an example of asynchronous message communication used in MCM.

Hello World Example
Video Tutorial
Download MCM

What advantages does MCM offer?

MCM offers all advantages of the asynchronous message communication. Additionally it offers simplified code syntax and transparent usage pattern (receive message, execute command, send message). Creating code using Visual Studio Templates is easy and makes the code reliable.

Loose coupling

The residents (components) don’t need to know anything about each other. New residents can settle in the village, some can move out.

Env.Components.Add(new Component1());
Env.Components.Add(new Component2());
They communicate using messages.

var message = new HelloRequestMessage("John");
or communicate directly with each other

var peopleCount = Env.Components.First<PeopleCountComponent>().Count;
They behave according to incoming messages.

private void handleHelloRequestMessage(HelloRequestMessage m) { }
[MessageSubscriber("Messages", UIThreadSynchronizationMode.PostAsynchronousInUIThread)]
private void handleHelloRequestMessage(HelloRequestMessage m) { }
Additional message types can come without redesigning the system architecture.

Not freezing UI

All messages are sent asynchronously and proceeded one after another (message channel uses a dedicated thread). Your task as the village head is only coordinating the residents work (manage components state according to incoming messages).

Unit Tests

The work is made using commands. The command is processed in a single thread. The command environment is defined in the command argument. Using mocks and simulating test environment is very easy.

Retry, Abort & Timeouts

In case the smith is busy or on vacation, he cannot make the razor (a resource is not available). The barber can resend the request message after some time.


Centralized message transport is a great value for the debugging. You can hire a detective (attach a listener to the message channel) and intercept every incoming message. Due to loose coupling – no system redesign is needed. The detective can broadcast specially prepared messages forcing the residents to behave in a particular way.

Macro recording

The village archive can store some messages. These messages could be later restored and replayed offering the macro functionality.


Due to storing messages in the archive, their restoring order can be reverted. This way you easily offer undo functionality.


The request for a new razor does not need to be sent by the barber. A macro can simulate a particular behavior of the village residents (pressing buttons, selecting list items etc.). That's how tutorials are made.

What are the main features of MCM?

  • No XML configuration, only C# programming
  • No InvalidCastExceptions due to C# generics
  • Very simple pattern - receive message, execute command, send message
  • Support for Intellisense (visual context help of visual studio)
  • Great extensibility - only basic message and command interaction provided. You build additional layers for advanced scenarios.
  • Easy and reliable code creating using Visual Studio Templates

Why use MCM instead of more advanced frameworks?

The more complex is the framework, the more time is needed to master it - Possessing a Boeing 747 is nothing if you cannot fly it ;-)

Hello World Example
Video Tutorial
Download MCM

Last edited Mar 4, 2013 at 6:55 AM by polo, version 11