void IBufferedState <TSelf> .Update(TSelf oldState, TimeSpan elapsed) { OnUpdate(oldState, elapsed); updateables.ApplyChanges(); Parallel.ForEach(updateables, updateable => updateable.Update(BufferIndex, elapsed)); }
private static void GameLoop_ResourceUpdateRequested(object sender, EventArgs e) { Parallel.ForEach(Resources, resource => { if (resource.IsReady) { if (resource.UpdateMode == UpdateMode.Synchronous || resource.UpdateMode == UpdateMode.InitAsynchronous) { resource.ApplyChanges(); } else { Task.Factory.StartNew(() => { resource.IsReady = false; resource.ApplyChanges(); resource.IsReady = true; }, TaskCreationOptions.PreferFairness); } } }); Resources.ApplyChanges(); }