void UpdatebagASSync(Bag <EntitySystem> temp) { tasks.Clear(); for (int i = 0, j = temp.Size; i < j; i++) { EntitySystem es = temp.Get(i); #if WINDOWS tasks.Add(factory.StartNew( #else tasks.Add(Parallel.Start( #endif () => { es.Process(); } )); } #if WINDOWS Task.WaitAll(tasks.ToArray()); #else foreach (var item in tasks) { item.Wait(); } #endif }
void UpdatebagASSync(Bag <EntitySystem> temp) { tasks.Clear(); for (int i = 0, j = temp.Size(); i < j; i++) { EntitySystem es = temp.Get(i); tasks.Add(factory.StartNew( () => { es.Process(); } )); } Task.WaitAll(tasks.ToArray()); }