public SizePropertyBag(IVirtualFolder owner, AsyncCompletedEventHandler completed)
 {
     if (owner is ICloneable)
     {
         this.FOwner = (IVirtualFolder) ((ICloneable) owner).Clone();
     }
     else
     {
         this.FOwner = owner;
     }
     this.FOwnerParent = owner.Parent as IVirtualCachedFolder;
     this.FCompleted = completed;
 }
 private void WatchFolder(IVirtualCachedFolder folder, bool watch)
 {
     int num;
     if ((this.WatchFolderMap != null) && this.WatchFolderMap.TryGetValue(folder, out num))
     {
         num += watch ? 1 : -1;
         if (num == 0)
         {
             folder.OnChanged -= new EventHandler<VirtualItemChangedEventArgs>(this.FolderChanged);
             this.WatchFolderMap.Remove(folder);
         }
         else
         {
             this.WatchFolderMap[folder] = num;
         }
     }
     else if (watch)
     {
         if (this.WatchFolderMap == null)
         {
             this.WatchFolderMap = new Dictionary<IVirtualCachedFolder, int>();
         }
         folder.OnChanged += new EventHandler<VirtualItemChangedEventArgs>(this.FolderChanged);
         this.WatchFolderMap.Add(folder, 1);
     }
 }
 private void CalculateFolderSize(object value)
 {
     Stack<IVirtualFolder> stack = new Stack<IVirtualFolder>();
     stack.Push(this.FOwner);
     Exception error = null;
     Stopwatch stopwatch = new Stopwatch();
     stopwatch.Start();
     try
     {
         while (stack.Count > 0)
         {
             using (IVirtualFolder folder = stack.Pop())
             {
                 foreach (IVirtualItem item in folder.GetContent())
                 {
                     if (item is IVirtualFolder)
                     {
                         stack.Push((IVirtualFolder) item);
                     }
                     else
                     {
                         object obj2 = item[3];
                         if (obj2 != null)
                         {
                             this.Size += (long) obj2;
                         }
                         obj2 = item[5];
                         if (obj2 != null)
                         {
                             this.CompressedSize += Convert.ToInt64(obj2);
                         }
                         if ((this.FOwnerParent != null) && (stopwatch.ElapsedMilliseconds >= 500L))
                         {
                             stopwatch.Reset();
                             this.FOwnerParent.RaiseChanged(WatcherChangeTypes.Changed, this.FOwner);
                             stopwatch.Start();
                         }
                     }
                 }
             }
         }
     }
     catch (Exception exception2)
     {
         error = exception2;
     }
     finally
     {
         stopwatch.Stop();
         if (this.FOwnerParent != null)
         {
             this.FOwnerParent.RaiseChanged(WatcherChangeTypes.Changed, this.FOwner);
         }
         this.FOwner = null;
         this.FOwnerParent = null;
         if (this.FCompleted != null)
         {
             this.FCompleted(this, new AsyncCompletedEventArgs(error, false, null));
             this.FCompleted = null;
         }
     }
 }