Game Development Reference
In-Depth Information
Responsive Processing
Launching the splash screen is simple enough, but the complexity of the solution
increases when the component must facilitate the processing of jobs. Single-
threaded applications typically hang when a long-running process executes, and
the application must wait to dispatch its usual messages. It is important that the
user interface remain responsive while jobs are being processed.
The MethodInvoker mechanism provides a generic delegate that is used to invoke a
method with a void parameter list. This mechanism can be used when you need a
simple delegate but do not want to create one yourself. MethodInvoker is used by
jobs to notify the application when processing status has changed. The application
defines a method that updates the status text label and calls Application.DoEvents()
to allow the application to update the user interface with the changes. This method
is bound to a MethodInvoker object and is passed to all jobs by the controlling logic.
The ProcessJobs() method has the code that creates a MethodInvoker bound to the
refresh method and then passes it to all jobs being processed.
With the addition of responsive job processing, the loading job component is now
complete and should resemble that shown in Figure 42.2. Notice the addition of
the status text label at the bottom of the form. The visibility of this label is con-
trolled by the DisplayStatus property in the settings and launcher class.
Figure 42.2 Preview of the splash screen dialog.
Search Nedrilad ::

Custom Search