Refresh Eto Form


(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.

Hi @em.rudelle,

Does this help?

– Dale

Hi @Dale, unfortunately no. I guess that it is because the queue is not proceed when using this function. It only queues the refresh.

@curtisw - is this something you can help with?

Hi @em.rudelle,

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:

    public async void OnCheckButton()
        _cleanLabel.Text = "Processing ..."; 
       await Task.Run(() => _nErrorGeometry = _bdIda.CheckGeometry());
        _cleanLabel.Text = "Done.";

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.

Hope this helps!


Hi @curtisw,
This was a very helpful answer. Thanks for the ressource, it gave me a very good introduction.

Hi @curtisw, @dale,

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.

Do you know a way to get me a bit further?