private void LoadAlbumBackground(object sender, DoWorkEventArgs e)
        {
            //albums = new List<PicasaEntry>();
              //albumIndex = -1;

              // Prepare for contact query
              string applicationName = "DigitalFrame";
              string username = settings.Username;
              string password = settings.Password;

              RequestSettings contactRequestSettings = new RequestSettings(applicationName, username, password);
              ContactsRequest contactRequest = new ContactsRequest(contactRequestSettings);

              // Request all groups of the auth user.
              //var allGroups = contactRequest.GetGroups();
              //foreach (var item in allGroups.Entries) {
              //  Debug.Write(item.Id + " - " + item.Title);
              //}

              // Get Family group entry.
              Group familyGroup;
              StringBuilder gs = new StringBuilder(GroupsQuery.CreateGroupsUri("default"));
              gs.Append("/");
              gs.Append("e"); // Family

              try {
            Feed<Group> gf = contactRequest.Get<Group>(new Uri(gs.ToString()));
            familyGroup = gf.Entries.First();
              }
              catch (AuthenticationException) {
            // We fail to get the group which means the login failed.
            return;
              }
              catch (GDataRequestException) {
            return;
              }

              // Get all contacts in Family group.
              ContactsQuery contactQuery = new ContactsQuery(ContactsQuery.CreateContactsUri("default"));
              contactQuery.Group = familyGroup.Id;
              Feed<Contact> friends = contactRequest.Get<Contact>(contactQuery);

              // Prepare for picasa query
              service = new PicasaService(applicationName);
              service.setUserCredentials(username, password);
              service.SetAuthenticationToken(service.QueryAuthenticationToken());

              allPhotos = new List<PicasaEntry>();

              foreach (var contact in friends.Entries) {
            try {
              string friendUsername = ParseUserName(contact);
              if (!string.IsNullOrEmpty(friendUsername)) {
            AlbumQuery query = new AlbumQuery();
            query.Uri = new Uri(PicasaQuery.CreatePicasaUri(friendUsername));

            PicasaFeed picasaFeed = service.Query(query);
            if (picasaFeed != null && picasaFeed.Entries.Count > 0) {
              foreach (PicasaEntry albumEntry in picasaFeed.Entries) {
                PhotoQuery photosQuery = new PhotoQuery(albumEntry.FeedUri);
                var photosFeed = (PicasaFeed)service.Query(photosQuery);
                foreach (PicasaEntry photoEntry in photosFeed.Entries) {
                  allPhotos.Add(photoEntry);
                }
              }
            }
              }
            }
            catch (LoggedException) {
              // Ignore the exception and continue.
            }
              }
        }