Dear all, good evening!
I am using a Thread to execute a routine for creating and indexing files (DBF), so far so good. In the same Thread I open the files, but when I close the Thread and try to use a file, I get the message that it is not open. Is there a way to get around this?
Thank you in advance for your attention!
Oliveiros Junior
hb_threadStart
Re: hb_threadStart
You need to use the sharing mode when you open the file.
line ID: ssbbstw
WeChat ID: ssbbstw
WeChat ID: ssbbstw
-
oliveiros junior
- Posts: 148
- Joined: Tue Mar 20, 2007 3:13 pm
Re: hb_threadStart
Olá ssbbs, obrigado pela resposta.
Como seria essa abertura compartilhada. Poderia dar um exemplo?
Att.,
Oliveiros Junior
Como seria essa abertura compartilhada. Poderia dar um exemplo?
Att.,
Oliveiros Junior
Re: hb_threadStart
Olá Oliveiros,
Seria algo assim: USE (cTab) INDEX (cIndex) ALIAS (cAlias) NEW SHARED
Seria algo assim: USE (cTab) INDEX (cIndex) ALIAS (cAlias) NEW SHARED
-
JoséQuintas
- Posts: 104
- Joined: Tue Feb 09, 2021 4:20 pm
Re: hb_threadStart
No.oliveiros junior wrote: Tue Jun 24, 2025 11:52 pm I am using a Thread to execute a routine for creating and indexing files (DBF), so far so good. In the same Thread I open the files, but when I close the Thread and try to use a file, I get the message that it is not open. Is there a way to get around this?
This is harbour default, and it is the best way to use multithread.
Each thread is like an EXE.
Files are opened on one thread, not on another.
On multithread you can use CLOSE DATABASES and only DBF on that thread will be closed.
I do not make full use of fivewin, may be code is wrong:
Code: Select all | Expand
USE ARQ1 SHARED
hb_ThreadStart( { || test() } )
browse()
CLOSE DATABASES
...
FUNCTION Test()
USE ARQ1 SHARED
browse()
CLOSE DATABASES
RETURN Nil
CLOSE DATABASES will close only file on that thread.
The best: you can change index order, record position, apply filter, and one thread do not change another.
Caution about this:
Create dialog on one thread and run on another thread is not the same as make all on same thread.
José M. C. Quintas Brazil
gtwvg, fivewin 25.12, hwgui, mingw 15.2 (32 bits)
-
oliveiros junior
- Posts: 148
- Joined: Tue Mar 20, 2007 3:13 pm
Re: hb_threadStart
Fala Junior,
Harbour MT tem as WORKAREA separado, cada thread tem sua propria WORKAREA.
Eu costumo abrir o banco de dados dentro da minha thread, faco o que precisa e automaticamente quando a thread finaliza, ela ira liberar o workarea ( dbCloseArea() ).
Voce pode abrir o mesmo DBF em varias thread pois sao totalmente individualizado.
Nota:
Existe mandeira de compartilhar, se nao me engano tem os comandos hb_dbRequest e hb_dbDetach que permite fazer uns paranaue
porem deixa so mais complexo.

Harbour MT tem as WORKAREA separado, cada thread tem sua propria WORKAREA.
Eu costumo abrir o banco de dados dentro da minha thread, faco o que precisa e automaticamente quando a thread finaliza, ela ira liberar o workarea ( dbCloseArea() ).
Voce pode abrir o mesmo DBF em varias thread pois sao totalmente individualizado.
Nota:
Existe mandeira de compartilhar, se nao me engano tem os comandos hb_dbRequest e hb_dbDetach que permite fazer uns paranaue
porem deixa so mais complexo.
Regards,
Lailton Fernando Mariano
Lailton Fernando Mariano