locked
Updating a ListView from a Service Every 5 seconds RRS feed

  • Question

  • User342340 posted

    Good Day All

    i have a ListView that is defined in a Xamarin Form. i want this ListView to be updated with the Data from the DB every 5 seconds. In a Non Mobile environment , we have a Windows Service , which is a long running Service. but now i search i came across a Service. but now i see this is implemented differently on each platform. Most examples i get are examples where one is binding the Control in Android Project. WhatUp if my Data binding is done in Xamarin Form (Standard Class) .

    1) Can i kindly have the example link or code that refresh any control from a Service that runs in Intervals 2) Update the control that is hosting in a PLC or Standard Class

    Thanks

    Monday, October 15, 2018 10:00 AM

Answers

  • User342340 posted

    Telerik Radchat has resolved my issue. it has all functionality that i need built in. https://www.telerik.com/xamarin-ui/conversational-ui

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Tuesday, October 16, 2018 9:42 PM

All replies

  • User364855 posted

    @VuyiswaMaseko

    1) Can i kindly have the example link or code that refresh any control from a Service that runs in Intervals Neither Android nor Ios will allow your service or background task run without restriction. https://docs.microsoft.com/en-us/xamarin/android/app-fundamentals/services/#background-execution-limits-in-android-80 https://docs.microsoft.com/en-us/xamarin/ios/app-fundamentals/backgrounding/ios-backgrounding-techniques/ios-backgrounding-with-tasks You could only do it when your app is in the foreground. In Xamarin.Forms, you could try to use Device.StartTimer(TimeSpan, Func<Boolean>) method to retrieve data from database. And update your control.

    2) Update the control that is hosting in a PLC or Standard Class Please check the following link: https://stackoverflow.com/questions/27857975/xamarin-form-update-listview-itemsource If you want to pass the data form native project to Forms project, you could try to use MessagingCenter.

    Tuesday, October 16, 2018 2:02 AM
  • User89714 posted

    @VuyiswaMaseko said: Good Day All

    i have a ListView that is defined in a Xamarin Form. i want this ListView to be updated with the Data from the DB every 5 seconds. In a Non Mobile environment , we have a Windows Service , which is a long running Service. but now i search i came across a Service. but now i see this is implemented differently on each platform. Most examples i get are examples where one is binding the Control in Android Project. WhatUp if my Data binding is done in Xamarin Form (Standard Class) .

    1) Can i kindly have the example link or code that refresh any control from a Service that runs in Intervals 2) Update the control that is hosting in a PLC or Standard Class

    Thanks

    I am assuming that the DB is not on the local device but instead on a remote server. Is that the case?

    Your ListView should use Data Binding so that it updates automatically from a View Model. Similarly, your View Model should be updated when changes occur to the (data) Model.

    What you don't want, is for your app to be polling the DB. Instead, your app should receive notifications/updates from a web server when changes occur - those notifications should be pushed from the web server to the app instead of using polling from the app end. When those updates are received by the app, it updates its Model, which results in updates to the View Model, which results in updates to the ListView. It's all pushed, not polled.

    If you Google MVVM, Data Binding, Push Notifications, in the context of Xamarin Forms, you should find plenty of information about how to do this.

    Tuesday, October 16, 2018 9:34 AM
  • User342340 posted

    Telerik Radchat has resolved my issue. it has all functionality that i need built in. https://www.telerik.com/xamarin-ui/conversational-ui

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Tuesday, October 16, 2018 9:42 PM