Game Development Reference
In-Depth Information
Simple Example
Now that development of the component is complete, we can finally start using it!
The example presented in this chapter has a form with two buttons where one
launches a splash screen and the other launches a loading dialog. The user interface
code will not be discussed because it is redundant and rudimentary, but the full
source code can be found on the Companion Web site.
We will start off by building three sample jobs that can be used to test the loading
dialog and show how to properly implement the ILoadingJob interface. Finally, the
code will be shown that properly configures the component to function as a splash
screen or a loading dialog.
The first sample job merely waits for two seconds before completing. This wait
time is to simulate actual processing that would occur if the job did something
remotely useful. The StatusText property will be used by the job manager to
update the processing status, so it is important that this property always return the
most up-to-date description of the operation.
public class SampleLoadingJob1 : SplashScreenLibrary.ILoadingJob
public SplashScreenLibrary.LoadingResult Load(MethodInvoker refreshInvoker)
refreshInvoker.Method.Invoke(refreshInvoker.Target, new object[0]);
return SplashScreenLibrary.LoadingResult.Success;
public string StatusText
return “Processing Sample Job 1 : Waiting for 2 Seconds”;
You should notice the following line that invokes the method that refreshes the
status description.
refreshInvoker.Method.Invoke(refreshInvoker.Target, new object[0]);
The preceding code should never be altered, but it is important that this line appear
either before a job begins processing or before each task within a job begins processing.
Search Nedrilad ::

Custom Search