private JsonGoalList GetFromYa(string token = "") { string fullName = jsonPath + "/" + "Data2.json"; if (String.IsNullOrEmpty(token)) { string url = "https://oauth.yandex.ru/authorize?response_type=token&client_id=" + secret; try { Process.Start(url); } catch (Win32Exception) { var startInfo = new ProcessStartInfo(@"C:\Program Files\Internet Explorer\iexplore.exe", url); Process.Start(startInfo); } finally { } tokenWindow = new TokenWindow(); //tokenWindow.Owner = (Application.Current as App).MainWindow; tokenWindow.Closing += GetToken; tokenWindow.Show(); } else { Task t = Task.Run(() => DownloadJson()); //t.Wait(); if (t.IsCompletedSuccessfully) { MessageBox.Show("Succes"); return(GetJson(fullName)); } else { MessageBox.Show("NotExist"); } } return(null); }