complete-reference-vb_net_89
complete-reference-vb_net_89
running, if Abort was invoked, if the thread is sleeping, if the thread is stopped, and so on.
You can gain a significant performance boost by using an additional thread to cater to the request of a user to
engage in an operation that may require some lengthy processing time. Using the extra thread in this fashion is
pretty straightforward. Rather than putting the single application thread allocated to every application to work
on such a task, simply create the Thread object as shown in the preceding code and delegate it to the job of
managing the thread.
You also do not have to hard−code the thread creation code into any of your forms. Simply delegate to one of
the business objects referenced from the form. The object and its thread go off and do their work and the user
can continue without being any the wiser.
It looks simple enough. The difficulties arise when you need to create more threads that potentially go off and
collide with each other. You can imagine the problems if more than one maintenance Thread object was
created in the preceding code and they all tried to access the same files. One thread might start serializing a
file out to disk while another may be trying to serialize it back to the application. That's where the advanced
features provided by locks, monitors, thread pools, waits, and critical sections come into play. Reaching that
level is a thread for another day.
MDI Applications
The MDI application comprises a single containing parent form and a collection of MDI child windows. The
child windows, known as the "subwindows," present various interaction opportunities for the user as he or she
works with the application. An MDI parent form is not difficult to create. You can create the form using the
Windows Forms Designer, in a visual style, or nonvisually in code.
A form is made into an MDI parent form at design time by setting its IsMDIContainer property to True.
This can be done from the form's property editor or in code. Once this property is set to True, the form
becomes the MDI container and all other windows become its so−called children.
1. Create a Windows Application project from the File, New menu or from the Add, New Project menu
accessible from the Solution Explorer.
2. When the new form appears in the designer, click its body and select the IsMDIContainer property
from the Properties window. Set the property to True. The main body of the window disappears,
leaving a white canvas that serves as the backdrop for the interaction with the child windows. Child
windows can be expanded to fill this inner frame, and the menus of the child window can be merged
with the parent.
1. Switch to code view by right−clicking the form's icon in Solution Explorer and choosing View Code
from the form's context menus.
2. In the InitializeComponent method, add the following line of code:
Me.IsMDIContainer = True
573