Пример #1
0
        private async void buttonStart_Click(object sender, EventArgs e)
        {
            try
            {
                labelResult.Text    = ProcessingLabel;
                buttonStart.Enabled = false;

                var type      = (AlgorithmType)comboBox1.SelectedIndex;
                var input     = textBoxFileInput.Text;
                var fileInfo  = new FileInfo(input);
                var output    = $"{fileInfo.DirectoryName}/{fileInfo.Name}.hashes_{type.ToString().ToLower()}";
                var isAsync   = checkBoxIsAsync.Checked;
                var blockSize = (int)numericUpDown.Value;

                var hashService = new HashService(output, input, blockSize, isAsync, type);

                var result = string.Empty;
                await Task.Run(() => result = hashService.HashFile() + "");

                labelResult.Text = result;
            }
            catch (Exception exception)
            {
                labelResult.Text = exception.Message;
            }
            finally
            {
                buttonStart.Enabled = true;
            }
        }