Beispiel #1
0
        public async Task <bool> SaveConfigAsync(string key)
        {
            var configs = new HardwareConfig
            {
                CpuCoreCount       = Environment.ProcessorCount,
                ClockFrequency     = Process.GetCurrentProcess().TotalProcessorTime.TotalSeconds,
                RandomAccessMemory = (int)Process.GetCurrentProcess().WorkingSet64 / 1024,
                DiskSpace          = DriveInfo.GetDrives().Select(o => o.TotalFreeSpace).Sum()
            };

            var message = new SaveConfigMessage()
            {
                SessionKey = key, Config = configs
            };

            var deSerializedData = await GetDataAsync(message);

            switch (deSerializedData)
            {
            case ErrorMessage errorMessage:
                MessageBox.Show(errorMessage.Error);
                return(false);

            case SuccessfulMessage successfulMessage:
                MessageBox.Show(successfulMessage.ToString());
                return(true);

            default:
                throw new Exception();
            }
        }
Beispiel #2
0
 public void Handle(SaveConfigMessage message)
 {
     SaveData();
 }