Home Page
Articoli
Tips & Tricks
News
Forum
Archivio Forum
Blogs
Sondaggi
Rss
Video
Utenti
Chi Siamo
Contattaci
Username:
Password:
Login
Registrati ora!
Recupera Password
Home Page
Stanze Forum
App. WinForms / WPF .NET
Evento tick del timer non si avvia
venerdì 27 maggio 2005 - 17.00
Elenco Threads
Stanze Forum
Aggiungi ai Preferiti
Cerca nel forum
trinity
Profilo
| Guru
3.465
messaggi | Data Invio:
ven 27 mag 2005 - 17:00
Ragazzi
io ho due processi, deve partire il primo codice ossia un thread che esegue un upload su remoto e contemporaneamente deve partire il codice scritto nell'evento tick di un timer solo che quest'ultimo non parte mai il caso strano è che non si avvia appena parte il processo di upload, a questo punto ho pensati ad un doppio thread ma niente il timer non parte: vi posto tutto il codice, lo scritto veloce perchè devo risolverlo velocemente ma avrò sbagliato da qualche parte, potete darci un'occhiata?
dichiaro i thread
Private avvio = New System.Threading.Thread(AddressOf sendfile)
Private avvio1 = New System.Threading.Thread(AddressOf time)
'avvio i due thread:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
avvio = New System.Threading.Thread(AddressOf sendfile)
avvio.start()
avvio1 = New System.Threading.Thread(AddressOf time)
avvio1.start()
End Sub
1° thread
Private Sub sendfile()
SyncLock (Me)
Dim connesso As Boolean
connesso = InternetGetConnectedState(0&, 0&)
Dim cn As Integer
InternetGetConnectedState(cn, 0&)
If connesso = True Then
Try
Cursor.Current = Cursors.WaitCursor
Me.Label3.Text = "Inserimento metadati in corso..."
Me.Panel1.Visible = True
System.Windows.Forms.Application.DoEvents()
Dim str As String
str = "prova"
Dim result As Integer
result = Shell(str, AppWinStyle.MinimizedFocus,True)
System.Windows.Forms.Application.DoEvents()
If result = 0 Then
Me.Label3.Text = "Trasferimento in corso..."
End If
System.Windows.Forms.Application.DoEvents()
conn.setRemoteHost("192.168.0.1")
conn.setRemotePort(21)
conn.setRemoteUser("pippo")
conn.setRemotePass("prova")
conn.chdir("video")
System.Windows.Forms.Application.DoEvents()
conn.upload(Me.Label2.Text)
conn.chdir("")
conn.close()
System.Windows.Forms.Application.DoEvents()
Cursor.Current = Cursors.Default
Me.Panel1.Visible = False
MsgBox("Trasferimento terminato con successo")
avvio.stop()
avvio1.stop()
Timer1.Stop()
Timer1.Enabled = False
Catch
MsgBox(Err.Description)
conn.chdir("")
conn.close()
Cursor.Current = Cursors.Default
Me.Panel1.Visible = False
Exit Sub
End Try
Me.Panel2.Visible = True
System.Windows.Forms.Application.DoEvents()
Dim fr As New Form2
fr.caricadb()
System.Windows.Forms.Application.DoEvents()
Me.Panel2.Visible = False
fr.ShowDialog(Me)
Else
MsgBox("connessione internet non attiva")
End If
End SyncLock
End Sub
2° thread
Private Sub time()
SyncLock (Timer1)
Timer1.Enabled = True
Timer1.Start()
End SyncLock
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
On Error Resume Next
Dim gz As Integer
gz = conn.getFileSize("pedagna.flv")
Me.Label5.Text = gz
Me.Label5.Refresh()
End Sub
Torna su
Stanze Forum
Elenco Threads
Partecipa anche tu! Registrati!
Hai bisogno di aiuto ?
Perchè non ti registri subito?
Dopo esserti registrato potrai chiedere
aiuto sul nostro
Forum
oppure aiutare gli altri
Consulta le
Stanze
disponibili.
Registrati ora !