Beispiel #1
0
 /// <summary>
 /// Returns HomePageViewModel if viewmodel has been created previuously. Otherwise creates it and then returns it. Thread safe.
 /// </summary>
 /// <returns>HomeViewModel object</returns>
 public static HomePageViewModel GetHomePageViewModel()
 {
     LockingObject = new object();
     if (HomeVm == null)
     {
         lock (LockingObject)
         {
             if (HomeVm == null)
             {
                 HomeVm = new HomePageViewModel();
                 //this LoadHomePage() call out has to be done when homeVM is created, NOT when homeVM is called out.
                 //It can't be done in ctor because, homeVM won't be assinged a value and algorithm becomes indefitely recursive.
                 //Call it out here when homeVM has been assigned non-null value, so this part of code won't be reached again.
                 ////HomeVm.LoadHomePage();
             }
         }
     }
     return(HomeVm);
 }