PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2024 → Threads
Threads
Iniciado por guest, 16,mar. 2015 16:04 - 8 respuestas
Publicado el 16,marzo 2015 - 16:04
Hello everyone,
How can I execute threads on the background?
(the threads include file downloading)
Best regards,
Kozeta Leka
Publicado el 16,marzo 2015 - 16:30
Hi,

1. write your procedure to download the files etc...
2. run this procedure using the ThreadExecute command

<a class="ExternalLink" rel="nofollow" target="_blank" href="http://doc.windev.com/en-US/?3077024&product=WD&productversion=XXA150056M">http://doc.windev.com/en-US/&hellip;</a>

This should do it.
Regards,
Joris.
Publicado el 16,marzo 2015 - 16:51
I have actually tried it, but no files are downloaded.
Publicado el 17,marzo 2015 - 13:32
Hi,

And you are using code like this?
ThreadExecute("Test",threadNormal,ListFiles)
maybe you should insert some trace commands in your procedure to check where it goes wrong.

Regards,
Joris
Publicado el 18,marzo 2015 - 10:04
Yes, this is the way I am using it...and when I am debugging it line by line , it actually works. I use this code in the "onclick" event of a button. Maybe there is something wrong with that? I don't know.... I have never used threads before.
Publicado el 18,marzo 2015 - 10:21
Hi,

Keep in mind : don't use functions like info(...) or error(...) in your procedure.
Maybe that's the case ?

Regards,
Bart
Publicado el 18,marzo 2015 - 10:30
I do use info() but the procedure never goes that way....because info is used if there's an error during the connection to a web service.
I also use ignoreError and it is mandatory since I am using a web service that would not work other way...
Publicado el 18,marzo 2015 - 13:41
Hi Kozeta,

Be very diligent when working with thread, especially when you have no experience. Please, listen carefully to what has been posted up to now.

Here is a list of thing you can check:

1. Is your procedure working normally outside a thread?
2. Is your procedure making any interractions with the user interface? (Like Info() Message boxes, windows)? If yes, please absolutely remove that totally and use a different error reporting mechanism outside of the procedure.
3. Is your newly corrected procedure working outside the thread?
4. Make the thread very simply at first. Make the procedure an automatic procedure: http://doc.windev.com/en-US/…
5. Does this work?
6. Then remove this automatic procedure option. Call your procedure with ThreadExecute().
7. If this is not working, check if you are using many times the same thread at the same time. This is not possible in automatic thread management. You must use Critical sections and manage threads manually with critical sections. You do this with ThreadMode(): http://doc.windev.com/en-US/…

I hope this will help you. There was two lengthy threads in this forums couple months ago about the very same topic. Maybe this can be of help to you.
http://27130.foren.mysnip.de/read.php…
http://27130.foren.mysnip.de/read.php…

Best regards,
Alexandre Leclerc
Publicado el 18,marzo 2015 - 13:51
Thank you very much Alexandre!
I will check and see if it helps in my case.
Thanks agai! <img src="/NG2013_WEB/ui/smiley/1.gif" align=absmiddle border=0 alt=":)">
Best regards,
Kozeta Leka