コード例 #1
0
        private async void Decrypt()
        {
            try
            {
                var token = _token.Token;
                System.Diagnostics.Stopwatch objStopwatch = new System.Diagnostics.Stopwatch();
                objStopwatch.Start();
                var progress = new Progress <int>(s =>
                {
                    circularProgressBar1.Value = s;
                    circularProgressBar1.Text  = s.ToString() + "%";
                });
                string encryptedText = await Task.Factory.StartNew <string>(
                    () => _currentMode.Decrypt(_sfr, progress, token, _iv, _n),
                    TaskCreationOptions.LongRunning);

                WriteToFile(_path.Replace(".safer", ""), encryptedText);
                circularProgressBar1.Value = 100;
                circularProgressBar1.Text  = circularProgressBar1.Value.ToString() + "%";
                objStopwatch.Stop();
                labelTime.Text       = "Time: " + objStopwatch.Elapsed;
                buttonCancel.Enabled = false;
            }
            catch (OperationCanceledException)
            {
                MessageBox.Show("Cancelled");
            }
        }