Thanks. I found what I wanted in the Dispatcher class (which class Application uses). I needed to see more than I thought, because there is so much important code, however, what I originally was looking for was basically the following in Dispatcher.PushFrameImpl():
while(frame.Continue)
{
if (!GetMessage(ref msg, IntPtr.Zero, 0, 0))
break;
TranslateAndDispatchMessage(ref msg);
}
From this code I was led to learn about thread Frames and such.