In termini "tecnici" non so spiegartelo adeguatamente e brevemente..., quindi passo...posso soltanto dirti che, per quel che so, puoi gestire le Sub e la progressbar all'interno dell' evento 'Timer.Tick' e con una variabile che funge da contatore.
Nell' esempio sotto (2 form, 1 button, 1 progressbar, 1 timer) dove 'a' è uguale ad' "1,3,5,7,8" sono semplici "tempi di attesa", mentre se uguale a "2,4,6" i 'Console.WriteLine' vanno sostituiti con le tue Sub, 'a' = 9 ferma il timer e apre il form2.
Nota bene il 'ProgressBar1.Maximum = 8' mentre 'a' arriva a 9, l' IF a=9 non incrementa la progressbar visto che ha raggiunto il massimo con 'a=8'.
codice:Public Class Form1 Dim a As Integer Private Sub Form1_Load() Handles MyBase.Load ProgressBar1.Maximum = 8 Timer1.Interval = 1000 End Sub Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click Timer1.Start() End Sub Private Sub Timer1_Tick() Handles Timer1.Tick a = a + 1 If a = 1 Then ProgressBar1.Value = ProgressBar1.Value + 1 If a = 2 Then ProgressBar1.Value = ProgressBar1.Value + 1 Console.WriteLine("Estrapolazione dei dati dal db") End If If a = 3 Then ProgressBar1.Value = ProgressBar1.Value + 1 If a = 4 Then ProgressBar1.Value = ProgressBar1.Value + 1 Console.WriteLine("Caricamento nel dataset") End If If a = 5 Then ProgressBar1.Value = ProgressBar1.Value + 1 If a = 6 Then ProgressBar1.Value = ProgressBar1.Value + 1 Console.WriteLine("Caricamento del datagriedview nella seconda form") End If If a = 7 Then ProgressBar1.Value = ProgressBar1.Value + 1 If a = 8 Then ProgressBar1.Value = ProgressBar1.Value + 1 If a = 9 Then Timer1.Stop() Form2.Show() End If End Sub End Class![]()

...posso soltanto dirti che, per quel che so, puoi gestire le Sub e la progressbar all'interno dell' evento 'Timer.Tick' e con una variabile che funge da contatore.
Rispondi quotando