Reputation: 1445
What is difference between this three codes?
1.
Window a = new Window ();
a.Show (); // call show
Application b = new Application ();
b.Run (); // call without a
2.
Window a = new Window ();
// do not call show
Application b = new Application ();
b.Run (a); // with a
Why work both correctly? And why work this too? 3.
Window a = new Window ();
a.Show (); // call show and also call show bellow
Application b = new Application ();
b.Run (a); // with a
Upvotes: 1
Views: 206
Reputation: 13679
both are basically meant for message loop, it is the core of windows application which handles the window message like painting, mouse/kbd event etc.
if you use the code below without Application.Run
Window a = new Window ();
a.Show ();
you'll find a frozen window, the reason is that there is no one to tell that window to repaint or handle any event.
so by invoking a message loop via Application.Run
, the window starts to work as expected
Application b = new Application ();
b.Run (a); // with a
Upvotes: 3