(In C#) How is it possible to manually ask an Eto window/form to refresh ? Here is my goal :
In a personal class, derived from Eto.Forms.Form, when user hits a button, it lunches a long process. In order to give feedback to user, I’d like to update a status label. Here is the code of the raised function :
public void OnCheckButton()
{
_cleanLabel.Text = "Processing ..."; // User never see this, because window doesn't refresh
_nErrorGeometry = _bdIda.CheckGeometry(); // A function that takes a minute to run
_cleanLabel.Text = "Done.";
}
The user never sees the label with “Processsing …” written, because the window only refreshes in the end. I’ve noticed that if I prompt an Eto message in between, it will refresh the initial window. So I guess there is a way to do it.
The only effective way to make the UI responsive is to use a separate thread for background processing. One way to make it easy is with C# is via async/await, something like:
You do have to ensure you don’t update any UI in the background thread directly (created by Task.Run() above). If you do need to, use Application.Instance.Invoke/AsyncInvoke to call a method that updates the UI.
BTW, this is a great resource to get started with asynchronous programming if you are unfamiliar.
Do you know wether there is a python equivalent for this functionality? I have been looking into threading described in this topic. Unfortunately with no succes.