private async void Btn_avvia_Click(object sender, RoutedEventArgs e) { ct = new CancellationTokenSource(); Semaphore sem = new Semaphore(1, 2); IProgress <int> progress = new Progress <int>(UpdateUI); WorkerProgressAsync wrk = new WorkerProgressAsync(sem, ct, 10, 1000, progress); await wrk.start(); MessageBox.Show("Mi dimentico del thread secondario e non attendo il thread secondario per visualizzare questo messaggio"); }
private async void Start_Click(object sender, RoutedEventArgs e) { cts = new CancellationTokenSource(); //WorkerAsync wrk = new WorkerAsync(10, 1000, cts); IProgress <int> progress = new Progress <int>(UpdateUI); WorkerProgressAsync wrk = new WorkerProgressAsync(sem, 11, 1000, cts, progress); await wrk.start(); //WorkerProgress wrk = new WorkerProgress(10,1000,cts,progress); //wrk.start(); MessageBox.Show("posso farti leggere questo messaggio mentre sto anche contando"); }