void UpdateSpace(object sender, Web.GetFreeSpacePercentageCompletedEventArgs e) { if (e.Error != null || e.Result.Total == -1) { try { long freeBytesForUser, totalBytes, freeBytes; if (Win32.GetDiskFreeSpaceEx(Init.HomeDirectory, out freeBytesForUser, out totalBytes, out freeBytes)) { drivespaceprog.Maximum = totalBytes; drivespaceprog.Value = drivespaceprog.Maximum - freeBytes; freespace.Text = freespace.Text = "Free Space: " + parseLength(freeBytes); } } catch { drivespaceprog.Maximum = 0; } } else { drivespaceprog.Maximum = e.Result.Total; drivespaceprog.Value = e.Result.Used; freespace.Text = freespace.Text = "Free Space: " + parseLength(e.Result.Total - e.Result.Used); } totalspace.Text = "Total Space: " + parseLength(drivespaceprog.Maximum); if (drivespaceprog.Maximum > 0) { DriveSpace.Visibility = System.Windows.Visibility.Visible; decimal d = Math.Round(((Convert.ToDecimal(drivespaceprog.Value) / Convert.ToDecimal(drivespaceprog.Maximum)) * 100), 2); drivespaceper.Text = d + "%"; if ((100 - d) < 5 && !hasShownWarning) { if (Dialog.ShowMessageDialog("You are running low on Space\nTry deleting some old files to free up space", "Low Space", DialogIcon.Warning).HasValue) { hasShownWarning = true; } } if (us == null) { us = new Thread(new ThreadStart(updatespace)); us.Start(); } } }
void c_GetFreeSpacePercentageCompleted(object sender, Web.GetFreeSpacePercentageCompletedEventArgs e) { Dispatcher.BeginInvoke(new EventHandler <Web.GetFreeSpacePercentageCompletedEventArgs>(UpdateSpace), sender, e); }