public void GetBusStopList() { lock (_conn) { var stopsInDb = GetBusStopsFromDb(); if (!stopsInDb.Any()) { var client = GetClient(); client.GetBusStopsListCompleted += (s, e) => { var busStopsFromJson = new BusStopListConverter().GetBusStopsList(e.Result); AddStopsToDb(busStopsFromJson); }; client.GetBusStopsListAsync(Authentication); } } }
public void GetBusStopList(Action<List<BusStop>> callback) { var stopsInDb = GetBusStopsFromDb(); if (stopsInDb.Any()) { callback(stopsInDb); } else { var client = GetClient(); client.GetBusStopsListCompleted += (s,e) => { var busStopsFromJson = new BusStopListConverter().GetBusStopsList(e.Result); AddStopsToDb(busStopsFromJson); callback(busStopsFromJson); }; client.GetBusStopsListAsync(Authentication); } }