public void AsyncUpdate()
        {
            Popups.UILoading loading = null;
            this.Dispatcher.BeginInvoke(new Action(delegate()
            {
                loading = new Popups.UILoading("Loading Info");
                UIController.ShowPanel(loading);
            }));

            string[] skills = UIController.Proxy.GetSkills(UIController.MyProfile.Username, UIController.Password, _user.Username);

            this.Dispatcher.BeginInvoke(new Action(delegate()
            {
                if (skills.Length != 0)
                    SkillsPanel.Children.Clear();

                foreach (string skill in skills)
                {
                    TextBlock text = new TextBlock();
                    text.Text = skill;
                    text.Margin = new Thickness(5, 0, 0, 0);
                    SkillsPanel.Children.Add(text);
                }

                UIController.HidePanel(loading);
            }));
        }
        public void AsyncUpdate()
        {
            Popups.UILoading loading = null;
            this.Dispatcher.BeginInvoke(new Action(delegate()
            {
                loading = new Popups.UILoading("Loading Info");
                UIController.ShowPanel(loading);
            }));

            this.Dispatcher.BeginInvoke(new Action(delegate()
            {
                SkillsPanel.Children.Clear();
                SkillsPanel.Children.Add ( new UIDevelopers( _user));
                UIController.HidePanel(loading);
            }));
        }
        /// <summary>
        /// Update the lists of people in asyncronous way.
        /// </summary>
        private void AsyncUpdate()
        {
            Popups.UILoading loading = null;
            this.Dispatcher.BeginInvoke(new Action(delegate()
            {
                loading = new Popups.UILoading("Loading Profile");
                UIController.ShowPanel(loading);
            }));

            WUser me = UIController.Proxy.GetUser(UIController.MyProfile.Username, UIController.Password);
            if (me != null)
                UIController.MyProfile = me;

            WService[] services = UIController.Proxy.GetServices(UIController.MyProfile.Username, UIController.Password);

            this.Dispatcher.BeginInvoke(new Action(delegate()
            {
                Posts.Text = UIController.MyProfile.Statuses.ToString();
                Followings.Text = UIController.MyProfile.Followings.ToString();
                Followers.Text = UIController.MyProfile.Followers.ToString();

                if (String.IsNullOrEmpty(UIController.MyProfile.Avatar))
                    Avatar.InternalImage.Source = new BitmapImage(new Uri("pack://application:,,,/It.Uniba.Di.Cdg.SocialTfs.Client;component/Images/DefaultAvatar.png"));
                else
                    Avatar.InternalImage.Source = new BitmapImage(new Uri(UIController.MyProfile.Avatar));

                UserName.Text = UIController.MyProfile.Username;

                if (services.Length != 0)
                    Services.Children.Clear();
                foreach (WService s in services)
                {
                    Objects.UIService service = new Objects.UIService(s);
                    service.Click += service_Click;
                    Services.Children.Add(service);
                }
                UIController.HidePanel(loading);
            }));
        }
        /// <summary>
        /// Update the lists of people in asyncronous way.
        /// </summary>
        private void AsyncUpdate()
        {
            Popups.UILoading loading = null;
            this.Dispatcher.BeginInvoke(new Action(delegate()
            {
                loading = new Popups.UILoading("Loading People");
                UIController.ShowPanel(loading);
            }));

            WUser[] suggestion = UIController.Proxy.GetSuggestedFriends(UIController.MyProfile.Username, UIController.Password);
            WUser[] followings = UIController.Proxy.GetFollowings(UIController.MyProfile.Username, UIController.Password);
            WUser[] followers = UIController.Proxy.GetFollowers(UIController.MyProfile.Username, UIController.Password);
            WUser[] hidden = UIController.Proxy.GetHiddenUsers(UIController.MyProfile.Username, UIController.Password);

            this.Dispatcher.BeginInvoke(new Action(delegate()
            {
                Suggestion.Children.Clear();
                if (suggestion.Length == 0)
                {
                    TextBlock textBlock = new TextBlock();
                    textBlock.Text = "We have no suggestions for you.\nPlease try again soon.";
                    textBlock.TextWrapping = TextWrapping.Wrap;
                    textBlock.Margin = new Thickness(5);
                    Suggestion.Children.Add(textBlock);
                }
                foreach (WUser item in suggestion)
                {
                    Objects.UIPerson user = new Objects.UIPerson(item);
                    user.Click += user_Click;
                    Suggestion.Children.Add(user);
                }

                Followings.Children.Clear();
                if (followings.Length == 0)
                {
                    TextBlock textBlock = new TextBlock();
                    textBlock.Text = "You are following no one.";
                    textBlock.TextWrapping = TextWrapping.Wrap;
                    textBlock.Margin = new Thickness(5);
                    Followings.Children.Add(textBlock);
                }
                foreach (WUser item in followings)
                {
                    Objects.UIPerson user = new Objects.UIPerson(item);
                    user.Click += user_Click;
                    Followings.Children.Add(user);
                }

                Followers.Children.Clear();
                if (followers.Length == 0)
                {
                    TextBlock textBlock = new TextBlock();
                    textBlock.Text = "No one is following you.";
                    textBlock.TextWrapping = TextWrapping.Wrap;
                    textBlock.Margin = new Thickness(5);
                    Followers.Children.Add(textBlock);
                }
                foreach (WUser item in followers)
                {
                    Objects.UIPerson user = new Objects.UIPerson(item);
                    user.Click += user_Click;
                    Followers.Children.Add(user);
                }

                Hiddens.Children.Clear();
                if (hidden.Length == 0)
                {
                    TextBlock textBlock = new TextBlock();
                    textBlock.Text = "You have hidden no one.";
                    textBlock.TextWrapping = TextWrapping.Wrap;
                    textBlock.Margin = new Thickness(5);
                    Hiddens.Children.Add(textBlock);
                }
                foreach (WUser item in hidden)
                {
                    Objects.UIPerson user = new Objects.UIPerson(item);
                    user.Click += user_Click;
                    Hiddens.Children.Add(user);
                }

                UIController.HidePanel(loading);
            }));
        }
        private void Login(String formattedHost, String username, String password, bool savePassword, bool autoLogin)
        {
            Contract.Requires(String.IsNullOrEmpty(formattedHost));
            Contract.Requires(String.IsNullOrEmpty(username));
            Contract.Requires(String.IsNullOrEmpty(password));

            Popups.UILoading loading = null;
            this.Dispatcher.BeginInvoke(new Action(delegate()
            {
                loading = new Popups.UILoading("Login in progress");
                UIController.ShowPanel(loading);
            }));

            String error = String.Empty;
            try
            {
                UIController.Proxy = new SocialTFSProxyClient(formattedHost);

                if (UIController.Proxy.IsWebServiceRunning())
                {
                    WUser user = UIController.Proxy.GetUser(username, password);
                    if (user == null)
                        error = "Username or Password is not correct";
                    else
                    {
                        Setting.Default.ProxyHost = formattedHost;
                        Uri proxyUri = new Uri(formattedHost);
                        Setting.Default.ProxyRoot = proxyUri.Scheme + "://" + proxyUri.Authority;
                        Setting.Default.UserName = username;
                        Setting.Default.Password = password;
                        Setting.Default.SavePassword = savePassword;
                        if (savePassword)
                        {
                            Setting.Default.AutoLogin = autoLogin;
                        }
                        else
                        {
                            Setting.Default.Password = "";
                            Setting.Default.AutoLogin = false;
                        }
                        Setting.Default.Save();
                        UIController.Password = password;
                        UIController.Connected = true;
                    }
                }
                else
                {
                    error = "The connection with the Proxy failed";
                }
            }
            catch (UriFormatException)
            {
                error = "Server URI is not in a correct form";
                UIController.Proxy = null;
            }

            this.Dispatcher.BeginInvoke(new Action(delegate()
            {
                UIController.HidePanel(loading);
                if (error.Equals(String.Empty))
                {
                    UIController.ShowMainPanel();
                }
                else
                {
                    ErrorLabel.Content = error;
                    ErrorRow.Height = GridLength.Auto;
                }
                if (!savePassword)
                    Password.Clear();
            }));
        }
        private void UpdateTimeline()
        {
            lock (_lock)
            {
                while (true)
                {
                    WPost[] posts = new WPost[0];
                    Popups.UILoading loading = null;

                    if (_first == 0)
                    {
                        this.Dispatcher.BeginInvoke(new Action(delegate()
                        {
                            loading = new Popups.UILoading("Downloading posts");
                            UIController.ShowPanel(loading);
                        }));
                    }

                    switch (_timelineType)
                    {
                        case TimelineType.HomeTimeline:
                            posts = UIController.Proxy.GetHomeTimeline(UIController.MyProfile.Username, UIController.Password, _first);
                            break;
                        case TimelineType.PersonalTimeline:
                            posts = UIController.Proxy.GetUserTimeline(UIController.MyProfile.Username, UIController.Password, _owner.Username, _first);
                            break;
                        case TimelineType.DynamicTimeline:
                            posts = UIController.Proxy.GetIterationTimeline(UIController.MyProfile.Username, UIController.Password, _first);
                            break;
                        case TimelineType.InteractiveNetworkTimeline:
                            if (UIController.GetCurrentCollectionURL() != null)
                            {
                                Tuple<string, string> tempObject = UIController.GetActiveObject();
                                if (tempObject != null)
                                {
                                    if (tempObject.Item1 != _interactiveObject.Item1 || tempObject.Item2 != _interactiveObject.Item2)
                                    {
                                        _first = 0;
                                        _last = 0;
                                        this.Dispatcher.BeginInvoke(new Action(delegate()
                                            {
                                                UIController.HidePanel(loading);
                                                TimelineStackPanel.Children.Clear();
                                                loading = new Popups.UILoading("Downloading posts");
                                                UIController.ShowPanel(loading);
                                            }));
                                        _interactiveObject = tempObject;
                                    }
                                    posts = UIController.Proxy.GetInteractiveTimeline(UIController.MyProfile.Username, UIController.Password, UIController.GetCurrentCollectionURL(), _interactiveObject.Item1, _interactiveObject.Item2, _first);

                                    // Reload timeline if document change during posts download
                                    tempObject = UIController.GetActiveObject();
                                    if (tempObject.Item1 != _interactiveObject.Item1 || tempObject.Item2 != _interactiveObject.Item2)
                                    {
                                        this.Dispatcher.BeginInvoke(new Action(delegate()
                                            {
                                                UIController.HidePanel(loading);
                                            }));
                                        continue;
                                    }
                                }
                            }
                            else
                            {
                                _first = 0;
                                _last = 0;
                                this.Dispatcher.BeginInvoke(new Action(delegate()
                                {
                                    //TODO Displays a message informing the user that needs to connect to a TFS collection
                                    TimelineStackPanel.Children.Clear();
                                }));
                            }
                            break;
                    }

                    this.Dispatcher.BeginInvoke(new Action(delegate()
                    {
                        if (posts.Length > 0)
                        {
                            _first = posts.First().Id;
                            if (_last == 0)
                                _last = posts.Last().Id;
                            for (int i = 0; i < posts.Length; i++)
                                if (_timelineType == TimelineType.PersonalTimeline)
                                    TimelineStackPanel.Children.Insert(i, new UIPost(posts[i], false));
                                else
                                    TimelineStackPanel.Children.Insert(i, new UIPost(posts[i], true));
                        }

                        UIController.HidePanel(loading);
                    }));

                    Monitor.Wait(_lock, new TimeSpan(0, 1, 0));
                }
            }
        }