开发者

Silverlight and M-V-VM - Where should a timer live?

I'm creating a simple monitoring tool in Silverlight. It talks to a web service to retrieve the status information and store it in the ViewModel. This needs to happen once per minute so I'm going to add a timer for this purpose (probably a DispatcherTimer).

My question开发者_开发技巧 is, where should the timer go in an M-V-VM architecture? In the ViewModel or the View?


If you don't have a model then next best thing is to put timer (Observable.Timer would be much easier to use) into ViewModel. E.g. something like this:

Observable
    .Timer(TimeSpan.Zero, TimeSpan.FromMinutes(1))
    .SelectMany(_ => GetDataFromWebService())
    .Subscribe(UpdateViewModel)
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜