I'd spelunk them with Reflector to find out the nitty-gritty's, but my
earlier post gave the gist of it. The message loop is fairly simple:
1. Call PeekMessage to get messages for current thread. If there aren't any
and it's not a form loop then exit out of the loop
2. Call GetMessage on the current thread, and create a Message object from
it.
3. If it's a control, call PreProcessMessage on it, jumping to 6 if the
message was handled.
4. Translate virtual key codes messages to character messages
5. Dispatch the message to it's target
6. If this is for a form, and it's not closing, back to 1
(I've simplified it a bit, but you get the idea)
As I said before, DoEvents executes this procedure without a specific form,
Run(Form) the indicated form, and ShowDialog(Form) runs it with various
modal options set.
<fo******@yahoo.co.uk> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
When dealing with forms, it is much better to rely on the Framework
to handle the messaging for you (via Form.Show, Form.ShowDialog &
Application.Run) unless you have a really deep understanding of the
windows message pump.
This is purely for testing using NUnit. NUnitForms seems to rely on
Application.DoEvents and I was trying to work with that. Instead
I'm now doing something like
[Test]
public void Test1()
{
// make my form, etc
Thread thread = new Thread(new ThreadStart(OtherMethod));
thread.Start();
Application.Run()
}
public void OtherMethod()
{
// wait for a bit, do some stuff with the forms
Application.Exit()
}
repeat for other tests.
but this is the best I've come up with rather than 'the' way to do it.
It would
be nice to have a real understanding of how DoEvents and Run works so
that
I have the option of doing it anyway I want. Also I just like knowing
how things work.
Ta
F