hi,
i do want to use Thread which are call a Function.
i use Thread to "fill" Imagelist of Object and all in Function use Object ... except FOR ii
Question : will ii be "manipulate" by 2nd Thread when called twice
using Function twice with Object as Parameter ?
using Function twice with Object as Parameter ?
greeting,
Jimmy
Jimmy
- James Bott
- Posts: 4840
- Joined: Fri Nov 18, 2005 4:52 pm
- Location: San Diego, California, USA
- Contact:
Re: using Function twice with Object as Parameter ?
Jimmy,
I'm not sure I understand what you want to do but here is an example of adding a new sale amount to a oCustomer object using a function. Note that a customer object exists until you end it.
However, this type of function should be made into a Method of the oCustomer object, then you can do this:
James
I'm not sure I understand what you want to do but here is an example of adding a new sale amount to a oCustomer object using a function. Note that a customer object exists until you end it.
Code: Select all | Expand
Function addSale( oCustomer, nNewSale )
oCustomer:TotalSales := oCustomer:TotalSales: + nNewSale
Return nil
Code: Select all | Expand
oCustomer:AddSale( nSale )
? oCustomer:TotalSales
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Re: using Function twice with Object as Parameter ?
hi James,
thx for Answer
to use a Function twice (or more) is not Problem ... IF Function is "short" and "quick"
but i have to do a lot in Function and have a Variable "ii" in a FOR / NEXT
as i have 2 x TGrid() which each start a Thread so both "may" use Function at "same Time"
but what if Thread 1 is at ii = 99 and 2nd Thread start at ii = 1
---
my "Problem" was while i use a CLASS and can not call a Method using hb_threadStart()
all of them fail ...
so i use a Function which work but i´m not sure if it is "safe" this Way
now i found a Solution to use a Method "in" CLASS when using hb_threadStart()
i "think" that this is "safe" as each Object have its own Instance so Variable are not "visible Outside"
thx for Answer
to use a Function twice (or more) is not Problem ... IF Function is "short" and "quick"
but i have to do a lot in Function and have a Variable "ii" in a FOR / NEXT
Code: Select all | Expand
FOR ii := 1 TO nMax
cFilename := TRIM( ::aSource[ ii ] [ F_NAME ] )
but what if Thread 1 is at ii = 99 and 2nd Thread start at ii = 1
---
my "Problem" was while i use a CLASS and can not call a Method using hb_threadStart()
Code: Select all | Expand
hb_threadStart(@::MyMethod)
hb_threadStart(@oSelf:MyMethod)
hb_threadStart(@&MyMethod)
so i use a Function which work but i´m not sure if it is "safe" this Way
now i found a Solution to use a Method "in" CLASS when using hb_threadStart()
Code: Select all | Expand
bMethod := { || ::ImageThread() }
::hThread := hb_threadStart( HB_BITOR( HB_THREAD_INHERIT_PUBLIC, HB_THREAD_MEMVARS_COPY ), @bMethod )
greeting,
Jimmy
Jimmy