开发者

M-V-VM and BackgroundWorker

In my app, the BackgroundWorker (housekeeping task) checks for data to be deleted from the database. After the data has been deleted do I then remove that DataItem from the开发者_JAVA技巧 ViewModel or the Model?

(Yes, I'm new to MVVM and perhaps I don't understand it too well yet).

Thanks.


I'm not sure exactly what you're trying to accomplish, but I would caution about the Background Worker modifying the viewmodel as part it's DoWork method. Modifying the ViewModel suggests a change to the UI, which likely won't work since the DoWork method is not running on the UI thread.


It depends on how your model and your view model are implemented, but conceptually, I'd

  • remove the data from the model, which, in turn, should
    • cause the data to be removed from the database and
    • cause the view models to be notified, so that they can update their state appropriately.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜