void loadAddInUIMenuItem_Click(object sender, RoutedEventArgs e)
        {
//<SnippetGetUICode>
// Get add-in pipeline folder (the folder in which this application was launched from)
            string appPath = Environment.CurrentDirectory;

// Rebuild visual add-in pipeline
            string[] warnings = AddInStore.Rebuild(appPath);
            if (warnings.Length > 0)
            {
                string msg = "Could not rebuild pipeline:";
                foreach (string warning in warnings)
                {
                    msg += "\n" + warning;
                }
                MessageBox.Show(msg);
                return;
            }

// Activate add-in with Internet zone security isolation
            Collection <AddInToken> addInTokens = AddInStore.FindAddIns(typeof(IWPFAddInHostView), appPath);
            AddInToken wpfAddInToken            = addInTokens[0];

            this.wpfAddInHostView = wpfAddInToken.Activate <IWPFAddInHostView>(AddInSecurityLevel.Internet);

// Get and display add-in UI
            FrameworkElement addInUI = this.wpfAddInHostView.GetAddInUI();

            this.addInUIHostGrid.Children.Add(addInUI);
//</SnippetGetUICode>
        }
        //public void WorkThreadFunction(object name)
        //{
        //    try
        //    {
        //        AddInToken token = _selectedItem;

        //        _addin = token.Activate<HostView.WPFAddInHostView>(AddInSecurityLevel.FullTrust);
        //        ResourceUtil.Tabview.Add((String)name, _addin);
        //        Dispatcher.BeginInvoke((Action)delegate
        //        {
        //            UserControl con = (_addin as UserControl);
        //            userControlview.Content = con;
        //            userControlview.IsEnabled = !userControlview.IsEnabled;
        //        },
        //    DispatcherPriority.Normal);
        //    }
        //    catch (Exception ex)
        //    {

        //    }
        //}

        private void LogoutBlock_OnMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            if (!_loadready)
                return;
            ResourceUtil.Tabview.Clear();
            Account.Username = String.Empty;
            liveviewtab.Foreground = new SolidColorBrush(Colors.White);
            liveviewtab.Visibility = Visibility.Hidden;
            LivevieLine.Visibility = Visibility.Hidden;
            //_tokens.Clear();
            //LbxMenu.ItemsSource = null;
            if (_addin != null)
            {
                if(!_addin.EndMess(true))
                    return;
                //Unload the addIn
                ShutdownPlugin();
                //end
                _addin = null;
                LbxMenu.ItemsSource = null;
                _loadready = false;
            }
            //userControlview.Content = new UserControl();
            _liveView.DisposeAllScreen();
            ((ContentControl)_liveView.Parent).RemoveChild(_liveView);
            _liveView = null;
            userControlview.Content = null;
            _infoClient.Disconnect();
            //GC.Collect();
            //GC.WaitForPendingFinalizers();
            
            Login();
        }
        /// <summary>
        /// User change select item on listbox
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// 
        
        private void LbxMenu_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (LbxMenu.SelectedIndex != -1)
            {
                
                //Reset Live view tab to unselected
                liveviewtab.Foreground = new SolidColorBrush(Colors.White);
                //End
                if (!ResourceUtil.Tabview.ContainsKey(LbxMenu.SelectedIndex.ToString(CultureInfo.InvariantCulture)))
                {
                    _selectedItem = (AddInToken)LbxMenu.SelectedItem;
                    //Start Busy
                    
                    _busy.Start();
                    #region Test
                    //_backgroundWorker.RunWorkerAsync();
                    //Thread nThread = new Thread(new ParameterizedThreadStart(WorkThreadFunction));
                    //nThread.SetApartmentState(ApartmentState.STA);
                    //nThread.IsBackground = true;
                    //nThread.Start(LbxMenu.SelectedIndex.ToString(CultureInfo.InvariantCulture));
                    //var result = Task<UserControl>.Factory.StartNew(() =>
                    //    {
                    //        AddInToken token = _selectedItem;
                    //        try
                    //        {
                    //            UserControl con = new UserControl();
                    //            con = token.Activate<HostView.WPFAddInHostView>(AddInSecurityLevel.FullTrust);
                    //        }
                    //        catch (Exception ex)
                    //        {
                                
                    //        }

                    //        return null;
                    //    }
                    //);
                    //// Wait for the task opening the file to complete
                    //result.Wait();
                    //userControlview.Content = (result.Result);
                    #endregion

                    _loadready = false;
                    //Main thread create a Usercontrol
                    AddInToken token = _selectedItem;
                    _addin = token.Activate<HostView.IWPFAddInHostView>(AddInSecurityLevel.FullTrust);
                    if(!addInViews.Contains(_addin))
                        addInViews.Add(_addin);

                    FrameworkElement addInUI = this._addin.GetAddInUI();

                    ResourceUtil.Tabview.Add(LbxMenu.SelectedIndex.ToString(CultureInfo.InvariantCulture), addInUI as FrameworkElement);
                    userControlview.Content = addInUI;
                    
                    //End
                    //Stop Busy
                    _busy.Stop();
                    _loadready = true;
                    
                }
                else
                {
                    userControlview.Content = ResourceUtil.Tabview[LbxMenu.SelectedIndex.ToString(CultureInfo.InvariantCulture)];
                }
            }
        }