public void EndUpdate(IAsyncResult ar) { Verify.Argument.IsNotNull(ar, "ar"); Verify.State.IsTrue(_avatarLoading != null, "No async operation is running."); GravatarService.EndGetGravatar(ar); }
public IAsyncResult BeginUpdate() { lock (_sync) { if (_avatarLoading != null) { return(_avatarLoading); } _avatarLoading = GravatarService.BeginGetGravatar( OnAvatarLoaded, _email, DefaultGravatarType.wavatar, GravatarRating.g, 60); return(_avatarLoading); } }
private void OnAvatarLoaded(IAsyncResult ar) { lock (_sync) { _avatarLoading = null; try { _image = GravatarService.EndGetGravatar(ar); } catch { _image = new Bitmap(1, 1); } } InvokeUpdated(); }
public void Update() { lock (_sync) { Verify.State.IsTrue(_avatarLoading != null, "Async update is already running."); try { _image = GravatarService.GetGravatar( _email, DefaultGravatarType.wavatar, GravatarRating.g, 60); } catch { _image = new Bitmap(1, 1); } } InvokeUpdated(); }