static void Main() { using (MessageThread thread = new MessageThread()) { const int WM_COMMAND = 0x111; thread.MessageHandlers[WM_COMMAND] = (m) => { MessageBox.Show(m.Msg.ToString()); }; thread.PostMessage(WM_COMMAND, IntPtr.Zero, IntPtr.Zero); Console.ReadLine(); } }