WPF and active objects

I have a collection of "active objects". That is, objects that you must first update yourself. In turn, these objects should be used to update the WPF-based GUI.

In the past, I would simply include my own stream in each object, but this only makes sense when working with a finite number of objects with well-defined life cycles. Now I use objects that exist only if necessary in the form, so the life cycle is unpredictable. In addition, I can have dozens of objects that create calls to the database and web services.

Under normal conditions, the update interval is 1 second, but this can take up to 30 seconds due to timeouts.

So what design would you recommend?

+3
source share
3 answers

You can use one dispatcher (scheduler) for all or a group of active objects. A dispatcher can handle high priority tasks first, and then others. You can see an article on long active objects with code to find how to do this. In addition, I recommend looking at Half Sync / Half Async. If you have any questions, welcome.

+1
source

I am not an expert, but I just would like the objects to have an event indicating when they changed. The GUI can then update the necessary parts (easily using data binding and INotifyPropertyChanged) whenever it receives an event.

0
source

- , , "", , . , , , , .

If in the end there are no listeners for a specific object, it does not matter much, the data simply does not pass.

In the base update code, you can use one timer (or several or something suitable) to determine when to receive updates. Doing this as more data flow, and less “state update”, is likely to save a lot of common sense in the end.

0
source

Source: https://habr.com/ru/post/1730011/


All Articles