DevTrain Startseite SharePoint Camp ? In 5 Tagen zum SharePoint Profi!  
  
  
SUCHEN:  
ARTIKEL ONLINE: 525   

Kategorien
.NET
Datenbanken
Web
XML

Allgemein
Camp
Foren
Events
Persönliche Einstellungen
Registrieren
Prämien Shop
Kontakt
Impressum
Über DevTrain

Autoren



 

Forum: VB.NET | Thema: Re: How to know that a thread has finshed. | Von: Christian Hehtke ( 15.04.2006 18:50)

Hi Theo,

yeah i know where you made a mistake.

Private WithEvents evBFMF As clsFilesAndFolders

You never use it in the code sample but the ThreadComplete event is only handled for this instance.

So when you call

THR_Browse = New Threading.Thread(AddressOf BFMF.BrowseForFiles)

BFMF.dir = dirInfo
BFMF.exTensions = exTensions
BFMF.AL_MediaFileAndPath = AL_MediaFileAndPath

THR_Browse.Start()

its definately clear that the Sub BFMFeventHandler will never get executed because you did not add an handler to the bfmf instance.

It would work like this ...

Private Sub Search()
Dim bfmf As New clsFilesAndFolders
Dim THR_Browse As New Threading.Thread(AddressOf bfmf.BrowseForFiles)
bfmf.dir = New IO.DirectoryInfo("c:\windows\system32")
bfmf.exTensions = New String() {".exe"}
AddHandler bfmf.ThreadComplete, AddressOf BFMFeventHandler
THR_Browse.Start()
End Sub

Sub BFMFeventHandler(ByVal AL_MediaFileAndPath As ArrayList)
MsgBox("Thread has finished.")
End Sub

Class BrowseForFiles ....
.....

this should make the messagebox appear, because i added the handler to the correct instance.
i did not check any logical things in this code so i did not worry about the messagebox beeing displayed 1000 of times during my test.

if there is any problem with the the file searching process i am willing to send you a similar class that i wrote 2 years ago it has process event etc.
but i would have to search for it on my hdds.
so please let me know if this suggestion fixed you problems

Mfg


Betreff Von Datum
Re: How to know that a thread has finshed.
Oh sorry i forgot to post you a little example of how to implement such a scenario under use of delegates.<br><br>Here it is. It executes a "verylongrunningtask" and then pops up a messagebox.<br><br> ...
Christian Hehtke 15.04.2006 18:54
Re: How to know that a thread has finshed.
Daer Christian,<br><br>Thank you very much for your answer.<br>MY first problem solved. After I changed the HANDLER I got the message.<br><br>The solution is out of my intellectual range (newbie), that means I...
G. Guest 16.04.2006 20:40
Re: How to know that a thread has finshed.
Hi Theo,<br><br>i would prefer a class like this you have a progress and you have a complete event and you can cancel the operation.<br>i did not test the cancel method ;)<br><br>hope it works for you...
Christian Hehtke 16.04.2006 23:36
Re: How to know that a thread has finshed.
Dear Christian,<br>Thank your very much for your effort to help me.<br><br>I have made another Project to test your code. It seems, your code is working fine.<br><br>In course of the next week I'm going to try...
Theo Driemann 17.04.2006 00:54
Re: How to know that a thread has finshed.
Dear Christian,<br><br>It is hard for me to follow the code you wrote, but it still works and I think it is even faster than my one. I added some lines, to catch errors when the program tries to access...
Theo Driemann 17.04.2006 18:39
Re: How to know that a thread has finshed.
you just have to call the Stop() method of the FileSearcher instance.<br><br>mfg
G. Guest 18.04.2006 08:56
Re: How to know that a thread has finshed.
Dear Christian,<br>Maybe you have time to answer the my last 2 question.<br><br>First, the stop method wasn't working, until I declared Dim fs As New clsSearchFiles.FileSearcher(_StartupDir, New...
G. Guest 20.04.2006 20:55
Re: How to know that a thread has finshed.
Dear Christian,<br>Maybe you have time to answer the my last 2 question.<br><br>First, the stop method wasn't working, until I declared Dim fs As New clsSearchFiles.FileSearcher(_StartupDir, New String()...
Theo Driemann 20.04.2006 21:28
Re: How to know that a thread has finshed.
i will take a look at the code this evening. <br><br>mfg
G. Guest 21.04.2006 09:16
Re: How to know that a thread has finshed.
hi, <br><br>i think you should read a book about object orientation.<br><br>if fixed the code and dropped the class you build because i did not see any sense in it sorry. <br><br>this is a short example... i let...
Christian Hehtke 22.04.2006 12:07
Re: How to know that a thread has...
Dear Christian.<br><br>Thanks a lot. Know I can use your code complete.<br><br>Your are right I have to read a book. But you remember, at the beginning of our dialog I mentoined that I am a newbie. <br><br>I'm in...
Theo Driemann 22.04.2006 17:59

Antworten
Vorsicht bei der Eingabe: Die Zeichen ' oder -- sind nicht erlaubt!

 Betreff:
 Nachricht: Den Beitrag finden Sie nun unter: http://beta.devtrain.de/foren Die Benutzerdaten und Foreninhalte von beta.devtrain.de und www.devtrain.de sind die selben.
Sie können sich dort sogar per RSS über neue Inhalte informieren lassen.
Bei Problemen bitte direkt Mail an asp [AT] ppedv.de.

 Signatur:

  



Login
Username:


Passwort:






Passwort vergessen?

Building und Connecting Know-how

© Copyright 2003 ppedv AG