Wpf and async

Hi all, my name is Vicente, i'm new in this forum, i'm writing from Spain (sorry for my english), firs of all i want to thank you for the great work in UrhoSharp, i'm a hobbyst gaming programmer, only do this for fun.

Now the question. I'm making a mixed application UrhoSharp in ControlHost & WPF, i'm trying to show the node properties of a node scene in a WPF control, but when i update the values of scene node, although i'm trying to update in a background task at minimum priority, every time the task updates values on WPF control the scene renders with some lag. Some sugestions to remove this lag?, thank you for read this post. Next the code i'm using: public void AsyncRefresh() { new Task(() => { if (uc != null) switch (uc.GetType().Name) { case "SceneNode": ((Property.SceneNode)uc).propGrid.Dispatcher.InvokeAsync((System.Action)(() => ((Property.SceneNode)uc).propGrid.Update()), System.Windows.Threading.DispatcherPriority.SystemIdle); break; default: break; } }, TaskCreationOptions.PreferFairness).Start(); }
(I subscribed to mouse move in Urho.Application.Input and then call from this event to method above, application is running under Windows 10 x64)

0

Best Answer

All actions over the nodes/scenes/components should be done from the game loop thread,
Consider using Application.InvokeOnMain(() => ) or use "await urhoApp.ToMainThreadAsync()" in order to dispatch actions to the game loop.

5

Answers

All actions over the nodes/scenes/components should be done from the game loop thread,
Consider using Application.InvokeOnMain(() => ) or use "await urhoApp.ToMainThreadAsync()" in order to dispatch actions to the game loop.