Ejemplo n.º 1
0
        public void LoadAllData()
        {
            Stopwatch sw = new Stopwatch();

            sw.Start();
            var AllFoodGroups = new FoodGroups(DBdirectory);

            AllNutrientDefs = new NutrientDefinitions(DBdirectory);
            AllFoods        = new Foods(DBdirectory);
            var AllNutrientValues = new NutrientsPerFood(DBdirectory);

            AllNutrientDefs.LoadFile();
            AllFoods.LoadFile();
            AllNutrientValues.LoadFile();
            AllFoodGroups.LoadFile();
            AllFoods.AssociateNutrientRows(AllNutrientValues, AllFoodGroups);

            // this is no faster, but it is an example of running tasks in parallel
            //List<Task> TaskList = new List<Task>();
            //TaskList.Add(Task.Run(() => AllNutrientDefs.LoadFile()));
            //TaskList.Add(Task.Run(() => AllFoods.LoadFile()));
            //TaskList.Add(Task.Run(() => AllNutrientValues.LoadFile()));
            //Task.WaitAll(TaskList.ToArray());
            sw.Stop();

            Double seconds = (Double)sw.ElapsedMilliseconds / 1000.0;
        }
Ejemplo n.º 2
0
 internal void AssociateNutrientRows(
    NutrientsPerFood AllNutrientValues, 
    FoodGroups allFoodGroups
    )
 {
    foreach(var food in this.allFoods)
    {
       food.Value.AssociateNutrientValues(AllNutrientValues.allValues[food.Key]);
       food.Value.AssignFoodGroup(allFoodGroups.allFoodGroups);
    }
 }