Visualizzazione dei risultati da 1 a 10 su 11

Visualizzazione discussione

  1. #10
    Utente di HTML.it
    Registrato dal
    Apr 2018
    Messaggi
    11
    codice:
    Imports System.Threading
    
    Public Class Form1
        Dim t As Thread
    
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            ProgressBar1.Minimum = 0
            ProgressBar1.Maximum = 1000
    
    
            t = New Threading.Thread(AddressOf LoadingProgressBar)
            t.Start()
        End Sub
    
    
        Private Sub LoadingProgressBar()
            Try
                Dim i As Integer
                Dim progress As Integer = 0
    
                For i = 0 To 1000
    
                    Me.Invoke(up, i)
                    Me.Invoke(updateStatus, i)
                    Me.Invoke(msg, i)
                    Thread.Sleep(1000)
                Next
    
    
                Me.Invoke(closeForm)
            Catch ex As ThreadAbortException
                Err.Clear()
                Me.Invoke(closeForm)
            End Try
        End Sub
    
        'Delegate method to allows other thread to update value of Progress Bar
        Private Delegate Sub updateProgress(ByVal val As Integer)
        Private up As New updateProgress(AddressOf UpdateValue)
    
        'Delegate method to allows other thread to close
        Private Delegate Sub closeMe()
        Private closeForm As New closeMe(AddressOf CloseSplash)
    
        'Delegate method to allows other thread to update text of Label Status
        Private Delegate Sub setStatus(ByVal status As Integer)
        Private updateStatus As New setStatus(AddressOf WriteLabel)
    
        Private Delegate Sub message(ByVal i As Integer)
        Private msg As New message(AddressOf messaggio)
    
    
    
        'UpdateValue method has been implemented to update value of progress Bar
        Private Sub UpdateValue(ByVal val As Integer)
            ProgressBar1.Value = val
        End Sub
    
        'WriteLabel
        Private Sub WriteLabel(ByVal text As String)
            lbl.Text = text
        End Sub
    
        Private Sub messaggio(i As Integer)
            MsgBox(i)
        End Sub
    
    
        'Close
        Private Sub CloseSplash()
            Me.Close()
        End Sub
    
    
        Private Sub Button1_Click_1(sender As Object, e As EventArgs) Handles Button1.Click
            t.Abort()
        End Sub
    End Class

    Grazie a te le cose adesso sono piu chiare, questo è un estratto d'esempio.
    quando parte il MSGbox il trhead si blocca quindi non è possibile adortire da tasto, invece io vorrei avere la possibilità di abortirlo ugualmente cliccando il Button1
    Ultima modifica di BoBoPoP; 22-05-2019 a 14:46

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.