Ver Mensaje Individual
  #6 (permalink)  
Antiguo 10/01/2010, 11:23
Avatar de Bazookao
Bazookao
 
Fecha de Ingreso: diciembre-2008
Ubicación: Mexico
Mensajes: 139
Antigüedad: 15 años, 4 meses
Puntos: 1
Respuesta: Eventos retardados en VB.NET

jiji muy bien muchas gracias bueno dejo el codigo traducido al VB.NET
Código VB.NET:
Ver original
  1. Imports System.Threading
  2.  
  3. Public Class Form6
  4.  
  5.     Private Delegate Sub Timer(ByVal timer As String)
  6.     Private timer1 As Timer
  7.  
  8.     Private time As Double = 0.0
  9.     Private timerStarted As Boolean = False
  10.     Private returnTime As String = String.Empty
  11.  
  12.     Private Sub UpdateTimer(ByVal time As String)
  13.         Me.lblTimerDisplay.Text = time
  14.  
  15.     End Sub
  16.  
  17.     Public Function Counter() As String
  18.         Return returnTime
  19.     End Function
  20.  
  21.     Private Sub DisplayTimer()
  22.         Do While timerStarted
  23.             time += 0.01
  24.             time = Convert.ToDouble(time.ToString("0.00"))
  25.             returnTime = Convert.ToString(time)
  26.             Me.lblTimerDisplay.Invoke(timer1, Counter)
  27.         Loop
  28.  
  29.  
  30.     End Sub
  31.  
  32.     Public Sub New()
  33.  
  34.         ' Llamada necesaria para el Diseñador de Windows Forms.
  35.         InitializeComponent()
  36.         timer1 = New Timer(AddressOf UpdateTimer)
  37.  
  38.     End Sub
  39.  
  40.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  41.         Dim starTimer As New System.Threading.Thread(AddressOf DisplayTimer)
  42.         timerStarted = True
  43.         starTimer.Start()
  44.     End Sub
  45.  
  46.     Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  47.         timerStarted = False
  48.     End Sub
  49. End Class