private void AbortDownload() { if (_wfr != null) { _wfr.Dispose(); _wfr = null; } }
void OnBackgroundDetect(object sender, DoWorkEventArgs e) { string versionFile = "/Versions_build.txt"; string versionFileUri = AppConfig.DownloadUriBase + versionFile; string tempVersionFile = Path.GetTempFileName(); bool detectOnDemand = (bool)e.Argument; WebFileRetriever retriever = null; try { retriever = new WebFileRetriever(AppConfig.ProxySettings, versionFileUri, tempVersionFile, false); StringBuilder sb = new StringBuilder(); if (Kernel32.GetPrivateProfileString(Constants.SuiteName, "Version", "1.0.0.0", sb, 255, tempVersionFile) > 0) { Version current = new Version(SuiteVersion.Version); Version available = new Version(sb.ToString()); if (available.CompareTo(current) > 0) { Logger.LogInfo("Current version: {0}, available on server: {1}. Update is required.", current, available); EventDispatch.DispatchEvent(EventNames.NewVersionAvailable, sb.ToString()); } else { Logger.LogInfo("Current version: {0}, available on server: {1}. Update is NOT required.", current, available); if (detectOnDemand) { EventDispatch.DispatchEvent(EventNames.ShowMessageBox, "TXT_NOUPDATEREQUIRED", "TXT_APP_NAME", MessageBoxIcon.Information); } } } } finally { if (retriever != null) { retriever.Dispose(); } } }