![]() ![]() AddHandler sets the method we want to execute in substitution of the UserInterfaceUpdate event handler of a Thread instance. In this case, the solution is simple and is the one we usually use to delegate the code to execute in the Action event of the Timer class. The second approach is the one we use when creating the Thread instances from code.Think about this as a bridge between our Thread and the main app thread. That is: every time we call the AddUserInterfaceUpdate method, the Thread will fire its UserInterfaceUpdate event. The UserInterfaceUpdate event is the new Event whose parameter will provide all the data we are interested in previously added from the Run event calling the AddUserInterfaceUpdate method. The Run event is the one intended to run the code usually associated with a long task, so it doesn’t freeze the responsiveness of the rest of the app (mainly the user interaction or user interface refreshes). Draging and droping an object from the Library panel to the Tray in the Window Layout, so the IDE creates a new instance that we can use to implement the Run and, now, also the UserInterfaceUpdate events.The two ways we can use the new thread class are the same available in previous releases: In addition, the overloaded AddUserInterfaceUpdate method also accepts a Dictionary as a parameter. The first (left) value of this pair will be the one acting as the Key for the Dictionary, while the second value of the pair (right) will be the value itself we want to forward to the main thread in order to update our user interface. ![]() In order to add new values to these dictionaries, we only need to call the AddUserInterfaceUpdate method, providing as parameter a Pair. This provides, as an Array of Dictionaries, all the values we need to pass along from the Run event of the running Thread. With Xojo 2019R2, everything related to updating the UI is much simpler thanks to the new UserInterfaceUpdate event in the Thread class. Doing that in previous releases required the use of a thread in combination with a Timer, for example. Xojo 2019R2 has a lot of new features and enhancements, including the simplification of updating the User Interface in apps from threads running in combination with the main app thread. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |