private void BtnThread_Click(object sender, RoutedEventArgs e) { Stopwatch stopWatch = new Stopwatch(); textOriginal = Text_Initial.Text; numar = textOriginal.Length / Environment.ProcessorCount; lista.Capacity = Environment.ProcessorCount; for (int i = 0; i < textOriginal.Length; i += numar) { if ((i + numar) < textOriginal.Length) { lista.Add(textOriginal.Substring(i, numar)); } else { lista.Add(textOriginal.Substring(i)); } } for (int k = 0; k < lista.Count; k++) { int temp = k; new Thread(() => { textReasamblat[temp] = CriptareDecriptare.Criptare(lista[temp]); }).Start(); } stopWatch.Start(); for (int i = 0; i < textReasamblat.Count; i++) { Criptat.Text += textReasamblat[i]; } stopWatch.Stop(); Durata.Text = String.Format("{00:00} ms", stopWatch.ElapsedMilliseconds); }
private void BtnExec_Click(object sender, RoutedEventArgs e) { Stopwatch stopWatch = new Stopwatch(); textOriginal = Text_Initial.Text; stopWatch.Start(); textCriptat = CriptareDecriptare.Criptare(textOriginal); stopWatch.Stop(); Durata.Text = String.Format("{00:00} ms", stopWatch.ElapsedMilliseconds); Criptat.Text = textCriptat; }