private void RunPendingRequests()
{
int maxStartId = -1;
BillingRequest request;
while (mPendingRequests.First != null && mPendingRequests.First.Value != null)
{
request = mPendingRequests.First.Value;
if (request.RunIfConnected())
{
// Remove the request
mPendingRequests.RemoveFirst();
// Remember the largest startId, which is the most recent
// request to start this service.
if (maxStartId < request.StartId)
{
maxStartId = request.StartId;
}
}
else
{
// The service crashed, so restart it. Note that this leaves
// the current request on the queue.
BindToMarketBillingService();
return;
}
}
// If we get here then all the requests ran successfully. If maxStartId
// is not -1, then one of the requests started the service, so we can
// stop it now.
if (maxStartId >= 0)
{
if (Consts.DEBUG)
{
Log.Info(TAG, "stopping service, startId: " + maxStartId);
}
StopSelf(maxStartId);
}
}