コード例 #1
0
        public bool Equals(HardDriveSpace hardDriveSpace)
        {
            if (hardDriveSpace == null)
            {
                return(false);
            }
            if (name != hardDriveSpace.name)
            {
                return(false);
            }
            if (label != hardDriveSpace.label)
            {
                return(false);
            }
            if (totalSize != hardDriveSpace.totalSize)
            {
                return(false);
            }
            if (totalFreeSpace != hardDriveSpace.totalFreeSpace)
            {
                return(false);
            }
            if (percentageFreeSpace != hardDriveSpace.percentageFreeSpace)
            {
                return(false);
            }


            return(true);
        }
コード例 #2
0
        private void Run()
        {
            var spaceInfos = DriveInfo.GetDrives().Where(d => d.IsReady).Select(d => new HardDriveSpace()
            {
                name                = d.Name,
                label               = d.VolumeLabel,
                totalSize           = d.TotalSize,
                totalFreeSpace      = d.TotalFreeSpace,
                percentageFreeSpace = (int)(((float)d.TotalFreeSpace / (float)d.TotalSize) * 100)
            }).ToList();


            if (previousResults == null || HardDriveSpace.Compare(spaceInfos, previousResults) == false)
            {
                callBack(spaceInfos);
            }

            previousResults = spaceInfos;

            Task.Delay(1000 * 120, cancellationToken.Token).ContinueWith((t) => Run(), cancellationToken.Token);
        }