public void Invoke(Action action) { if (ThreadID == Thread.CurrentThread.ManagedThreadId) action(); else PendingMainThreadActions.Add(action); }
void HandleClientPropertyChanged(object sender, PropertyChangedEventArgs e) { switch (e.PropertyName) { case "Position": UpdateCamera(); var sorter = new ChunkRenderer.ChunkSorter(new Coordinates3D( (int)Client.Position.X, 0, (int)Client.Position.Z)); PendingMainThreadActions.Add(() => ChunkMeshes.Sort(sorter)); break; } }