Game Development Reference
In-Depth Information
The second sample job shows how to execute multiple tasks within a job and cor-
rectly handle the StatusText property. The job executes 10 tasks, each one taking 0.6
seconds to complete.
public class SampleLoadingJob2 : SplashScreenLibrary.ILoadingJob
{
private int _currentTask = 1;
public SplashScreenLibrary.LoadingResult Load(MethodInvoker refreshInvoker)
{
for (_currentTask = 1; _currentTask <= 10; _currentTask++)
{
refreshInvoker.Method.Invoke(refreshInvoker.Target, new object[0]);
System.Threading.Thread.Sleep(600);
}
return SplashScreenLibrary.LoadingResult.Success;
}
public string StatusText
{
get
{
return String.Format(“Processing Sample Job 2 : Task {0} of 10”,
_currentTask);
}
}
}
This sample job works in a very similar way to the second sample job, except that
there are a greater number of tasks to complete and a much shorter waiting peri-
od between tasks.
public class SampleLoadingJob3 : SplashScreenLibrary.ILoadingJob
{
private int _currentTask = 1;
public SplashScreenLibrary.LoadingResult Load(MethodInvoker refreshInvoker)
{
for (_currentTask = 1; _currentTask <= 100; _currentTask++)
{
refreshInvoker.Method.Invoke(refreshInvoker.Target, new object[0]);
System.Threading.Thread.Sleep(50);
}
Search Nedrilad ::




Custom Search