-
-
Notifications
You must be signed in to change notification settings - Fork 314
Async call to update UI in UWP project #295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Here is an example. I get that the second one fires them off async which is why there's no pause.. from C# you'd call an await there (not sure how to do this from a Lua command or if it's possible). The first one (C# and Lua) included DOES delay for 2 seconds in between commands and doesn't lock the UI up. The second one does not.
What other ways can I approach this? |
Could you achieve this using |
I will test that out. |
@blakepell did you succeed ? Can you share some code ? |
He's a scenario I have in a UWP app I'm working on (this maybe more of a UWP question and less of an NLua question but I'd like input if any have it). I've written a mud client which is effectively like specialized telnet terminal that can execute commands, batches of commands, scripts, etc. I've exposed a C# object to Lua that allows it to execute sanctioned actions in the client (e.g. write to the terminal, send a command to the network, clear the terminal, etc.). This works mostly.
My problem is, the command runs sync even if I wrap it in an async call. The Lua executes but then doesn't end up updating the UI until the Lua Script is complete so you see everything fly by in a batch. It also hard to time commands since it won't execute, then wait for that previous command to go through to get an updated room variable for instance.
In the old WinForms days I'd have wrapped DoEvents and let Lua call that when it updates the UI (the terminal in my case is updated via binding to a list of strings). I can't seem to figure out how to Lua execute a script but allow updating in the UI in between Lua commands.
Here's an example of something that might be executed (the Sleep(3) is meant to give the previous command time to be sent and return, Sleep being a wrapper to various UWP techniques I've tried that pause).
The "Cmd:Send" command does work, but
The text was updated successfully, but these errors were encountered: