/// <summary> /// The BackgroundWorker Function responsible for checking Versions and Populating inital data on the application from the server. /// </summary> private void InitServerWorker_DoWork(object sender, DoWorkEventArgs e) { //init's class to communicate with external server ADFGXService.ServiceClient ADFGXserv = new ADFGXService.ServiceClient(); //Gets the News Information from Server and populates the News Textbox var retNews = ADFGXserv.GetNews(); if (retNews.Contains("ERROR:")) this.newsText.Invoke(new MethodInvoker(delegate () { this.newsText.Text = "An error occured while attempting to contact server! Please contact [email protected] to report the below error..." + Environment.NewLine + Environment.NewLine + retNews; })); else this.newsText.Invoke(new MethodInvoker(delegate () { this.newsText.Text = retNews; })); //Gets the Top20 results from Server and populates the Results Textbox var retTop = ADFGXserv.GetTop20(); if (retTop.Contains("ERROR:")) this.resultsText.Invoke(new MethodInvoker(delegate () { this.resultsText.Text = "An error occured while attempting to contact server! Please contact [email protected] to report the below error..." + Environment.NewLine + Environment.NewLine + retTop; })); else this.resultsText.Invoke(new MethodInvoker(delegate () { this.resultsText.Text = retTop; })); //Gets the currently being worked on Cipher var retCipher = ADFGXserv.GetCipher(); if (retTop.Contains("ERROR:")) { MessageBox.Show("An error occured while attempting to obtain the cipher to work on from the server. This is commonly because of a lack of internet connection. This application needs the internet to run. If this error continues after being connected, please ensure you can view the site http://fascinatinginformation.com/ and contact [email protected]" + Environment.NewLine + Environment.NewLine + retCipher, "ADFGX Cloud Factoring App"); } else Cipher = retCipher; //Gets the Version information from Server and exits if the Version is incorrect retVer = ADFGXserv.GetVersion(); if (retVer.Contains("ERROR:")) { MessageBox.Show("An error occured while attempting to check the version of the application with the server. This is commonly because of a lack of internet connection. This application needs the internet to run. If this error continues after being connected, please ensure you can view the site http://fascinatinginformation.com/ and contact [email protected]" + Environment.NewLine + Environment.NewLine + retVer, "ADFGX Cloud Factoring App"); Environment.Exit(0); } else if (retVer == "") { MessageBox.Show("An error occured while attempting to check the version of the application with the server. This is commonly because of a lack of internet connection. This application needs the internet to run. If this error continues after being connected, please ensure you can view the site http://fascinatinginformation.com/ and contact [email protected] . Exiting application to avoid wasting resources.", "ADFGX Cloud Factoring App"); Environment.Exit(0); } else { if (retVer != "3") { MessageBox.Show("A new version of the application has been released, thus running this version would be a waste. When exiting this messagebox the new version will be downloaded and ran.", "ADFGX Cloud Factoring App"); System.Net.WebClient myWebClient = new System.Net.WebClient(); myWebClient.DownloadFile("http://fascinatinginformation.com/ADFGX_Cloud_Solver.exe", "ADFGX_Cloud_Solver_" + retVer + ".exe"); System.Diagnostics.Process.Start("ADFGX_Cloud_Solver_" + retVer + ".exe"); Environment.Exit(0); } } }