I am new to Windows programming and trying to understand a client written in C#. This client listens to messages from a server and handles them. In this case, it is using C# application, forms and controls that I don't understand. Following is a sample code snippet. It creates an application context that I believe gets called when form is closed. It then connects to a server which sends this client messages and the callbackInterface is used to handle those messages. It creates a form and runs the application with the context created earlier. I believe this part runs a message loop until the form is closed.
Now I am trying to understand what is the point of creating these application context and forms and how they are being used in this case. Can someone help me understand the flow of things here and what role is played by these GUI controls? The client runs entirely in the background with no GUI interface. What is the advantage of using these controls over having a typical client application without these controls that just polls for server messages in a loop?
void start() {
// get application context
context = new ApplicationContext();
// connect to a server
connect(name, callbackInterface,...);
// creates a form
cform = new Form();
cform.createControl();
int dummy = cform.Handle.ToInt32();
Application.run(context);
// message loop has returned
disconnect(...)
}