In my app after login success, I need to start a thread which connecting to a wcf service for sync data between the app and a backend web. This process need to carry on every 1 minute and I should be able to start and stop this service from ui as well. Please advice me a proper way of doing it.
Currently what I've done was adding a async void
method and inside that method I'm running a while(isRunning)
loop. So from the Ui I can accessing the "isRunning
" variable and make it false to stop the process.
This is not entirely accurate because if the method is in middle of a http request with the WCF service, it will not interrupt.
I also can't use background worker
because sync function on the WCF service return pdf files (as data) and those were come as byte[]
My objective is to run this polling method keeping the UI responsiveness and impactless to the entire app.
If you want further clarification please ask.