Question about reusing code ...

Hi guys,

following situation ... i have a app with a connection to a sqlite database. in this database i have devices. in my app i read now from two views the sqlite database to get a list of all devices and a list of all fav. devices.

now, when a device is changing (is going on or offline) the bulb in the device is changing. for now i do it with observablecollections which is working very good but i have to observe the state in background of every device. so a user can put it on or off manually and not through the app so i have to check that.

my question now is, how can i combine this in one "collector" where i can get my list of data for the view i want (fav and all). actually i need to call two background processes which check my devices for the fav list and the all list. that is not the clean way isn't it?

my first try was to create a "collector" class which stores the list of devices in a observablecollection. in my view i only load this list and display it. it works but the auto refresh is not working, so i have to reload the view that i see changes ...

Answers

  • JamesLaveryJamesLavery GBBeta, University ✭✭✭✭✭
    Sounds like you need to decouple the UI and background processes more. I suggest you make the background processes raise events which you can handle on the UI thread. Then you can reload or refresh your list when things change.
Sign In or Register to comment.