Multithreads with FWH

Multithreads with FWH

Postby César E. Lozada » Sat Mar 22, 2008 3:47 am

Can they be implemented with FWH + xHarbour + BCC55?

If the answer is yes, who may help me?

Threads.prg exist into FWH\Samples but class Thread isn't into any library and no source code is found.

Thanks in advance.
César Lozada
User avatar
César E. Lozada
 
Posts: 128
Joined: Wed Oct 26, 2005 12:18 pm
Location: Los Teques, Miranda, Venezuela

Postby Antonio Linares » Sat Mar 22, 2008 6:13 am

César,

samples\thread.prg is just for Xbase++, not for Harbour/xharbour.

xharbour multithreading support is not fine. We are waiting for it to get improved and fully working.

Once there is a good support for threads in Harbour/xHarbour, then we will be able to adapt FWH to multithreading.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41321
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Multithreads with FWH

Postby César E. Lozada » Sun Mar 23, 2008 7:39 pm

Antonio:

Thanks so much for your very prompt answer.

I started this topic because StartThread(), StopThread() and WaitForThreads() work fine with console applications in xHarbour. But they cause a GPF with FWH.
User avatar
César E. Lozada
 
Posts: 128
Joined: Wed Oct 26, 2005 12:18 pm
Location: Los Teques, Miranda, Venezuela

Postby Antonio Linares » Sun Mar 23, 2008 8:34 pm

César,

I don't know for sure if threads support have been improved lately in xHarbour. Please read these comments from Przemek about threads implementation in xHarbour:

http://www.matrixlist.com/pipermail/har ... 02426.html

"... Of course the MT mode like in xHarbour can be added in a day or two but IMHO it's only waste of time as long as all internal structure will not be MT safe."

so it may work in console mode but it may not be robust enough for GUI apps that require multiple events support. Anyhow..

What do you need the threads for ? Maybe we can provide you an alternative way to do what you need.

Also keep in mind that you can use low level C language multithreading as it is 100% supported by the C compiler.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41321
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Multithreads with FWH

Postby César E. Lozada » Mon Mar 24, 2008 11:19 pm

Thanks again, Antonio.

DbSetFilter() is a time consuming function, but it is still faster than going from the top to the bottom (one record each time) into a large database. I'd like to execute a call to dbSetFilter() without losing the posibility of using a progress bar or an estimated time indicator. When filtering, the entire applications hangs up until filter is finished.

I thought in using multithreads to start the dbSetFilter() call, so I keep control on the application until it's done.

Maybe you have a better idea. Whatever it is, it will be welcome.

Regards
César Lozada
User avatar
César E. Lozada
 
Posts: 128
Joined: Wed Oct 26, 2005 12:18 pm
Location: Los Teques, Miranda, Venezuela

Postby Antonio Linares » Mon Mar 24, 2008 11:32 pm

César,

Have you considered to use a conditional index instead of DbSetFilter() ?

It will be much faster, and also, you can display a progress bar meanwhile the conditional index is created, without having to use multithreading.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41321
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby César E. Lozada » Tue Mar 25, 2008 5:47 am

No. I had not considered this option.

I'll take a look.

Thanks a lot.
User avatar
César E. Lozada
 
Posts: 128
Joined: Wed Oct 26, 2005 12:18 pm
Location: Los Teques, Miranda, Venezuela

Postby Otto » Tue Mar 25, 2008 6:04 am

Antonio,
would you be so kind to show how you make a conditional index.

For example I have a database test.dbf and a text.cdx.
What are the steps to make a conditional index?
Thanks in advance
Otto
User avatar
Otto
 
Posts: 6017
Joined: Fri Oct 07, 2005 7:07 pm

Postby nageswaragunupudi » Tue Mar 25, 2008 6:25 am

Mr Otto

Simple conditional index.

INDEX ON <expr> TAG <tagname> FOR <forcond>

Full syntax:
INDEX ON <indexExpr> ;
[TAG <cIndexName>] ;
[TO <cIndexFile>] ;
[FOR <lForCondition>] ;
[WHILE <lWhileCondition>] ;
[ALL] ;
[NEXT <nNumber>] ;
[RECORD <nRecNo>] ;
[REST] ;
[EVAL <bBlock>] ;
[EVERY <nInterval>] ;
[UNIQUE] ;
[ASCENDING|DESCENDING] ;
[USECURRENT] ;
[ADDITIVE] ;
[CUSTOM] ;
[NOOPTIMIZE] ;
[TEMPORARY] ;
[USEFILTER] ;
[EXCLUSIVE]

But if you are using DBFCDX, your filters are optimized and better you do not attempt creating conditional indexes.

If you want the filters to be optimized, you should be having regular indexes built on the fields, which are included in your filter expression.

Because your applications are multiuser, there are special issues you should consider while creating on the fly conditional indexes. Every index created should be in a different folder. Also some conditional indexes are not updated by further modifications of other users.

If you plan your indexes properly the speed of optimized filters overweigh the time taken for building on the fly conditional indexes. My advice is to plan your indexes properly and rely on the DBFCDX's optimization instead of creating indexes within the application and avoid dealing with issues specific to temporary indexes.

Slowness of filters and the need for creation of temporary indexes are relevant when you use DBFNTX.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10253
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Postby nageswaragunupudi » Tue Mar 25, 2008 6:43 am

> Also keep in mind that you can use low level C language multithreading as it is 100% supported by the C compiler.

I would be interested to know how to use C language multi-threading within a xHarbour + FWH application.

My need for multi-threading is very simple. I show browses of large tables from ADS server. I also show totals of certain columns in the footers. I get the totals using ADS Sql ( eg. SELECT SUM(DUES) FROM CUSTOMER WHERE <cond> ). The number of rows in the browse depend upon the options specified by the user. If the rows are too many the Sql query for totals take some time upto 30 secs. I do not want the user to wait.

I like to show the browse, make the sql query in another thread, and when the answer is ready refresh the footers.

ADS does not support Async queries ( ace32 or oledb). So that option is ruled out.

I think we do not know how far xharbour, adsrdd and fwh are multithread-safe. In any case I think adsrdd is not multithread compatible. If I know how to use C language multi threading within FWH + xHarbour application, I can write appropriate C code to use ACE32.DLL to query the server.

Without using multi-theads, I am aware I have a few other options, but I am more interested in using the multi-thread approach, if it is possible.

By the way, ADS Serverside filters work like miracle even with hundreds or users simultaneously accessing huge tables with million rows.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10253
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Postby Otto » Tue Mar 25, 2008 8:01 am

Mr. NagesWaraRao,
Thank you for your answer. I see “miracles don’t exist” considering all you wrote.

Regards,
Otto
User avatar
Otto
 
Posts: 6017
Joined: Fri Oct 07, 2005 7:07 pm

Postby Antonio Linares » Tue Mar 25, 2008 9:40 am

Nageswararao,

Using the Windows API: ( CreateThread() )
http://msdn2.microsoft.com/en-us/library/ms682453(VS.85).aspx

Without using the Windows API:
http://en.wikipedia.org/wiki/Beginthread
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41321
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Gale FORd » Tue Mar 25, 2008 1:37 pm

[TEMPORARY] option automatically creates unique index in temporary directory and deletes it for you.

I also combine range with temporary index with the [USECURRENT] option.
Gale FORd
 
Posts: 663
Joined: Mon Dec 05, 2005 11:22 pm
Location: Houston

Conditional index with CDX

Postby ukoenig » Tue Mar 25, 2008 2:16 pm

Hello Otto

I using Index-files for Filters with cdx
In a network i have done this :

The user can create his own index for a filter.
The index got the name of the Netuser-name.

My customer is satisfied and there are no problems at all
in a network.

Regards
Uwe
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Postby reinaldocrespo » Thu Apr 10, 2008 5:51 pm

Antonio/All;

Here is another example where threads could be very useful:

Suppose you have an xbrowse on a table of real time data, and while you have the browse in idle mode, someone inserts a new record to the table that pertains the data you are browsing. At the very least it would be nice to show a red dot somewhere to alert the user that he needs to refresh the browse to see newly inserted records.

So far I've been doing this with timers, but it is very inefficient and awkard at best.

This could be done with threads by having the app issue an "event" and have the browsing app listen for that specific threaded-event. ADS 9 adds support for notifications. A notification could be used on this example to inform a client application that data in a critical table has changed. The client app can then use this information to refresh the browse or turn a red dot somewhere without pausing to re-read the table every n seconds for critial updates. ie... no polling.

But ADS notifications are blocking calls (the call does not complete until a signal is received) therefore we would need to issue a new thread to attend this notifications and act accordingly all while the rest of the app goes on processing keystokes or whatever else.

Would you or someone else mind helping a bit more on how to use the C calls for multithreads from a fw app? I'd certainly like to test event notifications with ADS.

Thank you,


Reinaldo.
User avatar
reinaldocrespo
 
Posts: 972
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Silvio.Falconi and 17 guests