private void miDeleteItems_Click(object sender, RoutedEventArgs e) { Mouse.OverrideCursor = Cursors.Wait; sccmclictr.automation.functions.swcache.CacheInfoEx[] deletedItems = new sccmclictr.automation.functions.swcache.CacheInfoEx[dataGrid1.SelectedItems.Count]; dataGrid1.SelectedItems.CopyTo(deletedItems, 0); foreach (sccmclictr.automation.functions.swcache.CacheInfoEx CacheItem in deletedItems) { try { CacheItem.Delete(); iCache.Remove(CacheItem); } catch (Exception ex) { Listener.WriteError(ex.Message); } } dataGrid1.BeginInit(); dataGrid1.ItemsSource = null; dataGrid1.EndInit(); dataGrid1.BeginInit(); dataGrid1.ItemsSource = iCache; dataGrid1.EndInit(); try { uint?iTotalSize = 0; foreach (sccmclictr.automation.functions.swcache.CacheInfoEx CacheItem in iCache) { if (CacheItem.ContentSize != null) { iTotalSize = iTotalSize + CacheItem.ContentSize; } } sbiContentSize.Content = ((iTotalSize) / 1024).ToString() + " (MB)"; } catch { } Mouse.OverrideCursor = Cursors.Arrow; }