diff --git a/src/Avalonia.Base/Rendering/Composition/Compositor.cs b/src/Avalonia.Base/Rendering/Composition/Compositor.cs index 28c81dfb91..1bdae44cb9 100644 --- a/src/Avalonia.Base/Rendering/Composition/Compositor.cs +++ b/src/Avalonia.Base/Rendering/Composition/Compositor.cs @@ -62,6 +62,7 @@ namespace Avalonia.Rendering.Composition /// A task that completes when sent changes are applied and rendered on the render thread public Task RequestCommitAsync() { + Dispatcher.UIThread.VerifyAccess(); var batch = new Batch(); using (var writer = new BatchStreamWriter(batch.Changes, _batchMemoryPool, _batchObjectPool)) @@ -126,6 +127,7 @@ namespace Avalonia.Rendering.Composition internal void RegisterForSerialization(CompositionObject compositionObject) { + Dispatcher.UIThread.VerifyAccess(); _objectsForSerialization.Add(compositionObject); QueueImplicitBatchCommit(); }