Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

How To Keep Track when background services are executing/executed

$
0
0

Iam new to Xamarin, what I am trying to close that gap on a pattern used for messages. How do pages/view models know if a background service sent a message before that viewmodel was instantiated? How do I know if a background service IS running or just finished running a few mins ago or did the background service fail?

Scenario:
User on a Login Page logs in. We start a few background services

Download latest list of pdf files
Pull list of products available
Download a bunch of images
etc...
the the UI will open the persons' profile page and subscribe to each of the events and display data from the database once completed. In the navigation menu you can go to the products available page, when that pages loads I shows you all products available. How does the ProductsAvailableViewModel know if all products were downloaded, or did it fail to download. The message could have been sent prior to the viewmodel object instantiation.

I was thinking of solving the problem this way
1. Have a table in the SQLlite database that tracks all the messages sent by all services. A view model can query the events to see if a service is still working on pulling data, or if it recently failed and needs to be retried before showing any data on the screen.
OR
2. Having a "manager for each BG processor. That will start the BG process throughh a message and subscribe to the events of the BG Process and keeping the states in the "Manager" object. when going to sleep save state info in the Application.Current.Properties. Using Unity I will only have one instance of each object which then viewmodels/views can check info based on their needs

Is there a common pattern practice that is being used out there? I don't want to fall into some anti-pattern process which will have to be re-written.


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>