public void ElapsedTimer_MultiRun() { ElapsedTimer timer; timer = new ElapsedTimer(true); Thread.Sleep(1000); timer.Stop(); Thread.Sleep(1000); timer.Start(); Thread.Sleep(1000); timer.Stop(); Assert.IsTrue(Compare(2000, timer.ElapsedTime)); }
private void BtnInstall_OnClick(object sender, RoutedEventArgs e) { if (_installList.Count == 0) { MessageBox.Show(Localization.GetString("Global", 50), Localization.GetString("Global", 51)); return; } lblStatus.Text = Localization.GetString("Global", 48); pbProgress.Value = 0; pbProgress.Maximum = _installList.Count; lblProgress.Content = "0%"; dgUpdates.Disable(); rbnMain.IsEnabled = false; _tim = new ElapsedTimer(ref txtTime); _tim.Start(); var amountInstalled = 0; Task.Factory.StartNew(delegate { foreach (var currentFile in _installList) { currentFile.Status = currentFile.Install(); amountInstalled++; pbProgress.Dispatcher.BeginInvoke(new Action(() => { pbProgress.Value++; var progress = (pbProgress.Value / pbProgress.Maximum) * 100; lblStatus.Text = amountInstalled + " / " + _installList.Count + " " + Localization.GetString("Global", 62); lblProgress.Content = Math.Round(progress, 1) + "%"; dgUpdates.Items.Refresh(); })); } }).ContinueWith(continuation => { _tim.Stop(); lblStatus.Dispatcher.BeginInvoke(new Action(() => { lblStatus.Text = _installList.Count(c => c.Status == Status.Success) + " " + Localization.GetString("FrmLMM", 8); dgUpdates.Enable(); rbnMain.IsEnabled = true; })); }); }
public void ElapsedTimer_Reset() { ElapsedTimer timer; timer = new ElapsedTimer(true); Thread.Sleep(1000); timer.Stop(); Assert.IsTrue(Compare(1000, timer.ElapsedTime)); timer.Reset(); Assert.AreEqual(TimeSpan.Zero, timer.ElapsedTime); }
private async void addUpdate(IEnumerable <string> files) { dgUpdates.Disable(); pbProgress.Value = 0; lblProgress.Content = "0%"; var source = files.ToArray(); pbProgress.Maximum = source.Count(); _tim = new ElapsedTimer(ref txtTime); _tim.Start(); await Task.Factory.StartNew(delegate { Parallel.ForEach(source, new ParallelOptions { MaxDegreeOfParallelism = Options.MaxThreads }, currentFile => { _Update newUpdate = null; if (currentFile.EndsWithIgnoreCase(".cab")) { newUpdate = new CabUpdate(currentFile); } else if (currentFile.EndsWithIgnoreCase(".msu")) { newUpdate = new MsuUpdate(currentFile); } pbProgress.Increment(lblProgress); if (newUpdate == null) { return; } _updates.Add(newUpdate); }); }); _tim.Stop(); dgUpdates.ItemsSource = _updates; dgUpdates.Update(); }
public void ElapsedTimer_Basic() { ElapsedTimer timer; // Timer not started #1 timer = new ElapsedTimer(); Thread.Sleep(200); Assert.AreEqual(TimeSpan.Zero, timer.ElapsedTime); Thread.Sleep(1000); timer.Stop(); Assert.AreEqual(TimeSpan.Zero, timer.ElapsedTime); // Timer not started #2 timer = new ElapsedTimer(false); Thread.Sleep(200); Assert.AreEqual(TimeSpan.Zero, timer.ElapsedTime); Thread.Sleep(1000); timer.Stop(); Assert.AreEqual(TimeSpan.Zero, timer.ElapsedTime); // Timer started manually timer = new ElapsedTimer(false); Thread.Sleep(200); Assert.AreEqual(TimeSpan.Zero, timer.ElapsedTime); timer.Start(); Thread.Sleep(1000); timer.Stop(); Assert.IsTrue(Compare(1000, timer.ElapsedTime)); // Timer started automatically timer = new ElapsedTimer(true); Assert.AreEqual(TimeSpan.Zero, timer.ElapsedTime); timer.Start(); Thread.Sleep(1000); timer.Stop(); Assert.IsTrue(Compare(1000, timer.ElapsedTime)); }
public void SwitchConnection_BlastBoth() { // Simulate the blasting of events from the switch to the remote connection // and commands from the remote machine to the switch. var handlerDone = false; var cCommandsReceived = 0; var cCommandsExecuted = 0; var cEventsReceived = 0; var connectHandler = new EventHandler <SwitchInboundConnectionArgs>( (s, a) => { a.StartConnectionThread = false; Helper.EnqueueAction(() => { SwitchConnection serverConnection = a.Connection; serverConnection.CommandReceived += (s1, a1) => { if (a1.CommandText == "sendevent HEARTBEAT" && Helper.ASCIIEncoding.GetString(a1.Content) == "Hello World!" && a1.Properties["Foo"] == "Bar") { Interlocked.Increment(ref cCommandsReceived); } }; AuthHandshake(serverConnection, false); serverConnection.StartThread(); Helper.EnqueueAction( () => { for (int i = 0; i < TransactionCount; i++) { SendEvent(serverConnection, SwitchEventCode.Heartbeat, "Hello World!", new NameValue("Foo", "Bar")); } }); Helper.WaitFor(() => cCommandsReceived == TransactionCount && cCommandsExecuted == TransactionCount && cEventsReceived == TransactionCount, Timeout); serverConnection.Close(); handlerDone = true; }); }); SwitchConnection.InboundConnection += connectHandler; try { SwitchConnection.SendBufferSize = SwitchConnection.ReceiveBufferSize = SocketBufferSize; SwitchConnection.StartListener(binding, 10); var connection = new SwitchConnection(binding, SwitchConnection.DefaultPassword); var elapsedTimer = new ElapsedTimer(); connection.EventReceived += (s, a) => { if (a.EventCode == SwitchEventCode.Heartbeat && a.ContentType == "text" && a.ContentText == "Hello World!") { Interlocked.Increment(ref cEventsReceived); } }; connection.Connect(); elapsedTimer.Start(); for (int i = 0; i < TransactionCount; i++) { var properties = new ArgCollection(ArgCollectionType.Unconstrained); properties["Foo"] = "Bar"; connection.SendEvent(SwitchEventCode.Heartbeat, properties, "Hello World!"); Interlocked.Increment(ref cCommandsExecuted); } Helper.WaitFor(() => handlerDone, Timeout); elapsedTimer.Stop(); var rate = (cCommandsReceived + cEventsReceived) / elapsedTimer.ElapsedTime.TotalSeconds; Debug.WriteLine(string.Format("Transaction Rate: {0}/sec", rate)); } finally { SwitchConnection.ResetGlobals(); SwitchConnection.InboundConnection -= connectHandler; SwitchConnection.StopListener(); } }
public void SwitchConnection_BlastEvents() { // Simulate the blasting of events from the switch to the remote connection. var handlerDone = false; var cEventsReceived = 0; var connectHandler = new EventHandler <SwitchInboundConnectionArgs>( (s, a) => { a.StartConnectionThread = false; Helper.EnqueueAction(() => { SwitchConnection serverConnection = a.Connection; AuthHandshake(serverConnection, false); serverConnection.StartThread(); Helper.EnqueueAction( () => { for (int i = 0; i < TransactionCount; i++) { SendEvent(serverConnection, SwitchEventCode.Heartbeat, "Hello World!", new NameValue("Foo", "Bar")); } }); Helper.WaitFor(() => cEventsReceived == TransactionCount, Timeout); serverConnection.Close(); handlerDone = true; }); }); SwitchConnection.InboundConnection += connectHandler; try { SwitchConnection.SendBufferSize = SwitchConnection.ReceiveBufferSize = SocketBufferSize; SwitchConnection.StartListener(binding, 10); var connection = new SwitchConnection(binding, SwitchConnection.DefaultPassword); var elapsedTimer = new ElapsedTimer(); connection.EventReceived += (s, a) => { if (a.EventCode == SwitchEventCode.Heartbeat && a.ContentType == "text" && a.ContentText == "Hello World!") { Interlocked.Increment(ref cEventsReceived); } }; connection.Connect(); elapsedTimer.Start(); Helper.WaitFor(() => handlerDone, Timeout); elapsedTimer.Stop(); var rate = cEventsReceived / elapsedTimer.ElapsedTime.TotalSeconds; Debug.WriteLine(string.Format("Transaction Rate: {0}/sec", rate)); } finally { SwitchConnection.ResetGlobals(); SwitchConnection.InboundConnection -= connectHandler; SwitchConnection.StopListener(); } }
private async void BtnPrepare_OnClick(object sender, RoutedEventArgs e) { if (dgUSB.SelectedItems.Count != 1) { MessageBox.Show(Localization.GetString("Global", 69), Localization.GetString("Global", 68)); return; } var usb = (USBDrive)dgUSB.SelectedItems[0]; if (usb.LargerThan32Gb) { MessageBox.Show(Localization.GetString("FrmUSBPrep", 23), Localization.GetString("FrmUSBPrep", 24)); return; } var MBR = MessageBoxResult.None; if (usb.BootRecord == BootRecord.MBR && rbUEFI.IsChecked == true) { MBR = MessageBox.Show( Localization.GetString("FrmUSBPrep", 35) + " " + Localization.GetString("Global", 55) + "\n\n[" + Localization.GetString("FrmUSBPrep", 34) + "]", Localization.GetString("FrmUSBPrep", 25), MessageBoxButton.YesNo); } if (usb.BootRecord == BootRecord.GPT && rbBIOS.IsChecked == true) { MBR = MessageBox.Show( Localization.GetString("FrmUSBPrep", 36) + " " + Localization.GetString("Global", 55) + "\n\n[" + Localization.GetString("FrmUSBPrep", 34) + "]", Localization.GetString("FrmUSBPrep", 25), MessageBoxButton.YesNo); } if (MBR != MessageBoxResult.None && MBR != MessageBoxResult.Yes) { return; } Enable(false); watcher.Stop(); var elapsedTimer = new ElapsedTimer(ref txtTime); elapsedTimer.Start(); pbProgress.Value = 0; lblStatus.Text = Localization.GetString("FrmISOMaker", 18); var quickFormat = cbQuickFormat.IsChecked == true; var UEFI = rbUEFI.IsChecked == true; var newFormat = DriveFormat.FAT32; if (rbNTFS.IsChecked == true) { newFormat = DriveFormat.NTFS; } var result = string.Empty; usb.PropertyChanged += delegate(object o, PropertyChangedEventArgs args) { lblStatus.UpdateText(args.PropertyName); }; watcher.Stop(); await Task.Factory.StartNew(() => { if (UEFI) { result = usb.PrepareUSB_GPT(quickFormat, pbProgress); } else { result = usb.PrepareUSB_MBR(quickFormat, newFormat, pbProgress); } }).ContinueWith(delegate { elapsedTimer.Stop(); pbProgress.Value = 100; lblStatus.Text = "Done"; }, TaskScheduler.FromCurrentSynchronizationContext()); Scan(); }
public void IPToGeocode_UpdateData_WithQueries() { // Blast 100,000 parallel async queries at the the service // in waves of a 1000 queries at a time and during the middle of // this activity, prod the server to download a new database file // as often as possible. try { TestInit(true, true); int cQueries = 100000; int cWave = 1000; int cCompleted = 0; bool fail = false; ElapsedTimer timer = new ElapsedTimer(); int lastUpdateCount = 0; double rate; for (int i = 0; i < cQueries / cWave; i++) { cCompleted = 0; timer.Start(); for (int j = 0; j < cWave; j++) { client.BeginIPToGeoFix(testIP, ar => { var c = Interlocked.Increment(ref cCompleted); try { VerifyTestFix(client.EndIPToGeoFix(ar)); } catch { fail = true; } if (cCompleted == cWave) { timer.Stop(); } }, null); } Helper.WaitFor(() => cCompleted == cWave, TimeSpan.FromSeconds(60)); // Prod the server the first time through and then after the server // has completed downloading the previous update. if (i == 0 || server.IPGeocoder.UpdateCount > lastUpdateCount) { var oldDate = new DateTime(2000, 1, 1); try { File.SetCreationTimeUtc(IPGeocoder.DataPath, oldDate); File.SetLastWriteTimeUtc(IPGeocoder.DataPath, oldDate); File.SetLastAccessTimeUtc(IPGeocoder.DataPath, oldDate); lastUpdateCount = server.IPGeocoder.UpdateCount; server.IPGeocoder.PollForUpdates(); } catch (IOException) { // I'm going to ignore I/O errors because there's a decent // chance that the data file may be open in the geocoder's // download thread. } } } rate = cQueries / timer.ElapsedTime.TotalSeconds; Debug.WriteLine("{0} seconds elapsed for {1} queries", timer.ElapsedTime, cQueries); Debug.WriteLine("Query Rate: {0}/sec", rate); if (fail) { Assert.Fail("One or more of the query operations failed."); } } finally { server.IPGeocoder.StopImmediately = true; TestCleanup(); } }
public void IPToGeocode_Query_AsyncBlast() { // Blast 100,000 parallel async queries at the the service // in waves of a 1000 queries at a time. try { TestInit(true, true); int cQueries = 100000; int cWave = 1000; int cCompleted = 0; bool fail = false; ElapsedTimer timer = new ElapsedTimer(); double rate; for (int i = 0; i < cQueries / cWave; i++) { cCompleted = 0; timer.Start(); for (int j = 0; j < cWave; j++) { client.BeginIPToGeoFix(testIP, ar => { var c = Interlocked.Increment(ref cCompleted); try { VerifyTestFix(client.EndIPToGeoFix(ar)); } catch { fail = true; } if (cCompleted == cWave) { timer.Stop(); } }, null); } Helper.WaitFor(() => cCompleted == cWave, TimeSpan.FromSeconds(60)); } rate = cQueries / timer.ElapsedTime.TotalSeconds; Debug.WriteLine("{0} seconds elapsed for {1} queries", timer.ElapsedTime, cQueries); Debug.WriteLine("Query Rate: {0}/sec", rate); if (fail) { Assert.Fail("One or more of the query operations failed."); } } finally { TestCleanup(); } }
/// <summary> /// Implements the background thread. /// </summary> private void DownloadThread() { DateTime lastWarningTime = DateTime.MinValue; PolledTimer pollTimer; bool resetTimer; try { // Initialize the GeoTracker file folder try { Helper.CreateFileTree(dataPath); if (File.Exists(downloadPath)) { SysLog.LogWarning("GeoTracker: Deleting existing temporary [{0}] file on startup.", downloadPath); Helper.DeleteFile(downloadPath); } if (File.Exists(decryptedPath)) { SysLog.LogWarning("GeoTracker: Deleting existing temporary [{0}] file on startup.", decryptedPath); Helper.DeleteFile(decryptedPath); } } catch (Exception e) { SysLog.LogException(e); } // Initalize the poll timer. We'll schedule an immediate download if the data file does // not exist, otherwise we'll delay the polling for a random period of time between // 0 and 15 minutes in the hope that we'll end up staggering the polling times across // the server cluster (so we won't hammer the source website). pollTimer = new PolledTimer(settings.IPGeocodeSourcePollInterval, false); resetTimer = false; if (!File.Exists(dataPath)) { pollTimer.FireNow(); } else { pollTimer.ResetRandomTemporary(TimeSpan.Zero, TimeSpan.FromMinutes(15)); } // The polling loop. while (true) { if (stopPending) { return; } try { if (pollDataNow) { pollTimer.FireNow(); pollDataNow = false; } if (pollTimer.HasFired) { DateTime fileDateUtc = DateTime.UtcNow; bool isUpdate = false; double fileSize = 0; ElapsedTimer downloadTimer; HttpWebRequest request; HttpWebResponse response; HttpStatusCode statusCode; resetTimer = true; // If a database file already exists then extract its last modify // date and use this in an If-Modified-Since request to the source // website to see if there's an updated file. if (File.Exists(dataPath)) { request = (HttpWebRequest)WebRequest.Create(settings.IPGeocodeSourceUri); request.Timeout = (int)TimeSpan.FromSeconds(30).TotalMilliseconds; isUpdate = true; fileDateUtc = File.GetLastWriteTimeUtc(dataPath); request.Method = "HEAD"; request.IfModifiedSince = fileDateUtc; try { using (response = (HttpWebResponse)request.GetResponse()) statusCode = response.StatusCode; } catch (WebException e) { statusCode = ((HttpWebResponse)e.Response).StatusCode; } if (statusCode == HttpStatusCode.NotModified) { // The source website does not have an updated file. I'm going to // do one extra check to see if the file we have is more than 45 // days old and log a warning. Note that we're going to issue this // warning only once a week while the service is running. if (DateTime.UtcNow - fileDateUtc < TimeSpan.FromDays(45) || DateTime.UtcNow - lastWarningTime >= TimeSpan.FromDays(7)) { continue; } lastWarningTime = DateTime.UtcNow; const string warning = @"GeoTracker: The local copy of the MaxMind GeoIP City or GeoLite City database is [{0}] days old and should be updated. You may need to download a new copy of the database from http://maxmind.com, decompress it and upload it to the source website at [{1}]. Note: Make sure that the website is configured with the [.DAT=application/octet-stream] MIME mapping."; SysLog.LogWarning(warning, (int)(DateTime.UtcNow - fileDateUtc).TotalDays, settings.IPGeocodeSourceUri); continue; } } // Download the database to the temporary download file. Helper.DeleteFile(downloadPath); downloadTimer = new ElapsedTimer(true); fileSize = Helper.WebDownload(settings.IPGeocodeSourceUri, downloadPath, settings.IPGeocodeSourceTimeout, out response); downloadTimer.Stop(); // Set the file times to match the Last-Modified header received from the website (it any). string lastModified = response.Headers["Last-Modified"]; if (lastModified != null) { try { fileDateUtc = Helper.ParseInternetDate(lastModified); File.SetCreationTimeUtc(downloadPath, fileDateUtc); File.SetLastWriteTimeUtc(downloadPath, fileDateUtc); } catch (Exception e) { SysLog.LogException(e, "GeoTracker: Website for [{0}] returned invalid Last-Modified header [{1}].", settings.IPGeocodeSourceUri, lastModified); } } // Decrypt the file and set its file dates. var keyChain = new KeyChain(settings.IPGeocodeSourceRsaKey); using (var secureFile = new SecureFile(downloadPath, keyChain)) { secureFile.DecryptTo(decryptedPath); } File.SetCreationTimeUtc(decryptedPath, fileDateUtc); File.SetLastWriteTimeUtc(decryptedPath, fileDateUtc); // Verify the decrypted data file and then swap in new file. const string info = @"GeoTracker: {0} of IP-to-location database from [{1}] completed. Downloaded [{2:#.#}MB] bytes in [{3}]."; SysLog.LogInformation(info, isUpdate ? "Update download" : "Initial download", settings.IPGeocodeSourceUri, fileSize / (1024 * 1024), downloadTimer.ElapsedTime); // Create a new MaxMind lookup intance and then swap it in without interrupting // any queries in progress. try { LookupService newMaxMind; newMaxMind = new LookupService(decryptedPath, LookupService.GEOIP_MEMORY_CACHE); newMaxMind.close(); maxMind = newMaxMind; UpdateCount++; } catch (Exception e) { SysLog.LogException(e); SysLog.LogError("GeoTracker: The MaxMind downloaded database file [{0}] appears to be corrupted. This will be deleted so the downloader can get a fresh copy.", downloadPath); } lock (syncLock) { Helper.DeleteFile(dataPath); File.Copy(decryptedPath, dataPath); File.SetCreationTimeUtc(dataPath, fileDateUtc); File.SetLastWriteTimeUtc(dataPath, fileDateUtc); } // Delete the temporary files. Helper.DeleteFile(decryptedPath); Helper.DeleteFile(downloadPath); } } catch (WebException e) { SysLog.LogException(e); SysLog.LogWarning("GeoTracker: The download of the MaxMind database file has failed. The service will try again in 1 minute."); pollTimer.ResetTemporary(TimeSpan.FromMinutes(1)); resetTimer = false; } catch (ThreadAbortException e) { SysLog.LogException(e); throw; } catch (Exception e) { SysLog.LogException(e); } finally { if (resetTimer) { resetTimer = false; pollTimer.Reset(); } } Thread.Sleep(settings.BkInterval); } } finally { running = false; } }
private void StopElaspedTimer() { GameObject go = GameObject.Find("ElapsedTimer"); _elapsedTimer = (ElapsedTimer) go.GetComponent(typeof(ElapsedTimer)); _elapsedTimer.Stop(); }
private void BtnCreateISO_OnClick(object sender, RoutedEventArgs e) { if (btnCreateISO.Label == Localization.GetString("FrmISOMaker", 6)) { if (lblDirectory.Content.ToString().Equals(Localization.GetString("FrmISOMaker", 10))) { MessageBox.Show(Localization.GetString("FrmISOMaker", 10), ""); return; } if (lblISO.Content.ToString().Equals(Localization.GetString("FrmISOMaker", 9))) { MessageBox.Show(Localization.GetString("FrmISOMaker", 9), ""); return; } var directory = new DirectoryInfo(lblDirectory.Content.ToString()); var files = directory.GetFiles("*", SearchOption.AllDirectories); var filtered = files.Select(f => f) .Where(f => (f.Attributes & FileAttributes.Directory) != FileAttributes.Directory); if (!filtered.Any()) { MessageBox.Show(Localization.GetString("FrmISOMaker", 21), Localization.GetString("Global", 68)); return; } var timer = new ElapsedTimer(ref txtTime); timer.Start(); Enable(false); cancel = false; lblStatus.Text = Localization.GetString("FrmISOMaker", 18) + "..."; btnCreateISO.Label = Localization.GetString("Global", 66); var folder = lblDirectory.Content.ToString(); var isoPath = lblISO.Content.ToString(); iso = new ISO(folder, isoPath, txtLabel.Text); iso.ProgressChanged += iso_ProgressChanged; try { iso.CreateISO(); if (cancel) { pbProgress.Foreground = Brushes.Gold; DeleteISO(); lblStatus.Text = Localization.GetString("FrmISOMaker", 20); } else { lblStatus.Text = Localization.GetString("FrmISOMaker", 19); } } catch (Exception Ex) { DeleteISO(); lblStatus.Text = Localization.GetString("Global", 67) + ": " + Ex.Message; pbProgress.Foreground = Brushes.Red; } timer.Stop(); Enable(true); btnCreateISO.Label = Localization.GetString("FrmISOMaker", 6); btnCreateISO.IsEnabled = true; } else { cancel = true; pbProgress.Foreground = Brushes.Gold; btnCreateISO.IsEnabled = false; iso.Cancel(); } }
private void BtnConvert_OnClick(object sender, RoutedEventArgs e) { if (_conversionList.Count == 0) { MessageBox.Show(Localization.GetString("Global", 50), Localization.GetString("Global", 51)); return; } var output = lblOutput.Content.ToString(); if (!lblOutput.Content.ToString().ContainsIgnoreCase(":\\")) { MessageBox.Show(Localization.GetString("Global", 52), Localization.GetString("Global", 53)); return; } lblStatus.Text = Localization.GetString("Global", 48); pbProgress.Value = 0; pbProgress.Maximum = _conversionList.Count; lblProgress.Content = "0%"; dgUpdates.Disable(); rbnMain.IsEnabled = false; _tim = new ElapsedTimer(ref txtTime); _tim.Start(); var amountConverted = 0; Task.Factory.StartNew(delegate { Parallel.ForEach(_conversionList, new ParallelOptions { MaxDegreeOfParallelism = Options.MaxThreads }, currentFile => { currentFile.Status = currentFile.Convert(output); amountConverted++; pbProgress.Dispatcher.BeginInvoke(new Action(() => { pbProgress.Value++; var progress = (pbProgress.Value / pbProgress.Maximum) * 100; lblStatus.Text = amountConverted + " / " + _conversionList.Count + " " + Localization.GetString("Global", 49); lblProgress.Content = Math.Round(progress, 1) + "%"; dgUpdates.Items.Refresh(); })); }); }).ContinueWith(continuation => { IEnumerable <string> fileList = Directory.GetFiles(output, "*.xml", SearchOption.TopDirectoryOnly).ToArray(); if (!fileList.Any()) { return; } fileList = Directory.GetFiles(output, "*.msp", SearchOption.TopDirectoryOnly).ToArray(); if (!fileList.Any()) { return; } lblStatus.Dispatcher.BeginInvoke( new Action(() => { lblStatus.Text = Localization.GetString("Global", 47); })); Parallel.ForEach(fileList, new ParallelOptions { MaxDegreeOfParallelism = Options.MaxThreads }, xmlFile => { xmlFile = Path.GetDirectoryName(xmlFile) + "\\" + Path.GetFileNameWithoutExtension(xmlFile) + ".xml"; FileHandling.DeleteFile(xmlFile); }); }).ContinueWith(continuation => { _tim.Stop(); lblStatus.Dispatcher.BeginInvoke(new Action(() => { lblStatus.Text = _conversionList.Count(c => c.Status == Status.Success) + " " + Localization.GetString("FrmLMM", 8); dgUpdates.Enable(); rbnMain.IsEnabled = true; if (chkOpenExplorer.IsChecked == true) { Processes.OpenExplorer(output); } })); }); }