I have a Monodroid application that makes a lot of web requests. I make requests from events. Because of this, I need the queue to process my requests outside of my actions. This is to avoid creating multiple queries at the same time.
Since I am making my requests in another thread using ThreadPool.QueueUserWorkItem, it seems that if a user opens an action, starts a request, then returns, opens another action and starts another request before the first request finishes using web request blocking and no longer function.
What would be the best approach to the request task queue with callbacks outside the scope, or does anyone know / have an example of something like this? I think that he will need to deal with such cases as described above, where the activity can be closed / destroyed before the task is completed. This may mean that the task may be canceled or the task may be executed, but not update the user interface because it no longer exists.
In my case, the requests I make are in different functions that do different things, so callbacks for updating the user interface are not always the same functions. Also, the functions that I use to execute queries have different parameters. I am not sure that these points make it difficult / easier to create a solution to this problem, but I believe that I will need to rework a lot of code.
source share