private void BtnCloseCase_Click(object sender, RoutedEventArgs e)
        {
            ShowPopup = true;
            Button   button = sender as Button;
            OpenCase mycase = button.DataContext as OpenCase;

            CloseCaseNumber = mycase.CaseNumber;
        }
        //private static object _syncLock = new object();

        private async void DisplayCaseBasedOnEmail(string currentUserEmailID, string selectedSenderMailID, string selectedMailSubject)
        {
            try
            {
                string CaseBasedOnEmailURL = "";
                if (Globals.ThisAddIn.myCredentials != null)
                {
                    CaseBasedOnEmailURL = serverURL + "displayCaseBasedOnEmail.displaycase?rm_email=" + currentUserEmailID + "&email=" + selectedSenderMailID
                                          + "&subject=" + selectedMailSubject
                                          + "&access_token=" + Globals.ThisAddIn.myCredentials.AccessToken
                                          + "&instance_url=" + Globals.ThisAddIn.myCredentials.InstanceURL;
                    string CaseBasedOnEmailURLResponse = await WebRequestHelper.getResponseAsync(CaseBasedOnEmailURL);

                    if (CaseBasedOnEmailURLResponse != "" && !CaseBasedOnEmailURLResponse.Contains("null"))
                    {
                        var details = JObject.Parse(CaseBasedOnEmailURLResponse);
                        ClosedCaseCount = "Closed Case: " + details["totalClosedCaseEmail"].ToString();
                        OpenCaseCount   = "Open Case: " + details["totalOpenCaseEmail"].ToString();
                        var escaletedcasesArray = details["escalated_cases"];
                        var opencasesArray      = details["opencase"];
                        var autoRepliedCase     = details["autoreplied_case"];
                        var currentCase         = details["currentsubject"];
                        PositivePercentage = details["positive_percentage"].ToString();
                        NegativePercentage = details["nagative_percentage"].ToString();
                        NeutralPercentage  = details["neutral_percentage"].ToString();
                        List <OpenCase> tempList = currentCase.ToObject <List <OpenCase> >();
                        tempList.AddRange(escaletedcasesArray.ToObject <List <OpenCase> >());
                        tempList.AddRange(opencasesArray.ToObject <List <OpenCase> >());
                        tempList.AddRange(autoRepliedCase.ToObject <List <OpenCase> >());
                        //lock (_syncLock)
                        //{
                        //    EmailBasedCases = escaletedcasesArray.ToObject<List<OpenCase>>();
                        //    EmailBasedCases.AddRange(opencasesArray.ToObject<List<OpenCase>>());
                        //}
                        int index = tempList.FindIndex(a => a.CaseSubject == SelectedMailItem.Subject);
                        if (index >= 0)
                        {
                            OpenCase selectedCase = tempList[index];
                            selectedCase.IsSelectedCase = true;
                            tempList.RemoveAt(index);
                            tempList.Insert(0, selectedCase);
                        }

                        EmailBasedCases = tempList;
                        emailListBox.Dispatcher.Invoke((System.Windows.Forms.MethodInvoker) delegate {
                            emailListBox.Focus();
                        });
                    }
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show("Exception Occured in displayCaseBasedOnEmail API." + ex.Message);
            }
        }