empo
empo

Reputation: 1163

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 ViewModel or the Model?

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

Thanks.

Upvotes: 1

Views: 177

Answers (2)

Ralph Shillington
Ralph Shillington

Reputation: 21108

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.

Upvotes: 1

Heinzi
Heinzi

Reputation: 172468

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.

Upvotes: 0

Related Questions