Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.clipper.visual-objects > #5378
| From | Martin <spam@spam.spam> |
|---|---|
| Newsgroups | comp.lang.clipper.visual-objects |
| Subject | Re: Thread safe code - any caveats? |
| References | <WKWvt.136194$I84.63382@fx07.fr7> <51c03d5a$0$59644$c3e8da3$66d3cc2f@news.astraweb.com> <M9Xvt.159290$xf1.107935@fx16.fr7> <51c08d89$0$1698$c3e8da3$14a0410e@news.astraweb.com> |
| Message-ID | <yLdwt.151237$OL1.2491@fx13.fr7> (permalink) |
| Date | 2013-06-19 09:14 +0100 |
Hello Ginny
That is XBase++ code!
See thread crashing messages for the VO Code
Thanks
Martin
On 18/06/2013 17:41, Ginny Caughey wrote:
> I'm not sure what you mean by neatness of code, but I think you
> understand what I mean about threads being sort of the last choice to
> use. ;-)
>
> Given that this is VO, I'd try very hard to make this a separate app
> instead of a separate thread. The code you're showing me uses
> manipulates strings, for example. It looks like it wants to do something
> on the UI thread too, which you can't do from a worker thread. Instead
> you could pass a Windows message to the UI thread, which its dispatcher
> could interpret in some way. I'm also not seeing where you open and
> close the database on the worker thread. You can't manipulate the same
> workarea safely across threads.
>
> See my Serial class for an example of using a worker thread safely.
>
> Ginny
>
> "Martin" wrote in message news:M9Xvt.159290$xf1.107935@fx16.fr7...
>
> Thanks Ginny
>
> The main reason is neatness of code and communications.
>
> I will be sending the rack number in a PSZ in a struct but will need to
> search a DBF for it.
>
> This is the code I am converting, this is in XBase++, but need it in VO
> 2.8. AS you can see it is not especially long, and is stable, but I
> can't link in huge amounts of VO into Xbase++
>
> cBat := Left(cRack,10)
> // Now we could monitor order or rack
> IF TDelList->(DBSeek(cRack))
> TBarCode->(OrdSetFocus(2))
> TBarList->(OrdSetFocus(2))
>
> // Check the order
> cOrder := TDelList->DEL_Order
> IF TOrder->(DBSeek(cOrder))
> cCust := Torder->OD_CustNo
> ELSE
> cCust := 'xxxxxxxxxx'
> ENDIF
>
> lOk := .T.
> DO WHILE TDellist->DEL_Key == cBat .AND. !TDellist->(EoF())
> cOrder := TDelList->DEL_Order
> IF TOrder->(DBSeek(cOrder))
> IF cCust <> Torder->OD_CustNo
> EXIT
> ENDIF
>
> // Check the barcodes
> TBarCode->(DBSeek(cOrder))
> DO WHILE TBarCode->BC_Order == cOrder .AND. !TBarCode->(EoF())
> cBarcode := TBarCode->BC_Key
>
> IF !TBarList->(DBSeek(cProc+cBarcode))
> lOk := .F.
> EXIT
> ENDIF
>
> IF TBarList->PL_Qty <= 0
> lOk := .F.
> EXIT
> ENDIF
>
> TBarCode->(DBSkip(1))
> ENDDO
> ENDIF
> TDelList->(DBSkip(1))
> ENDDO
>
> IF lOk
> // Fully loaded!!!!
> // Hit_Key('fully loaded')
>
> nPos := AT(cErr,'OPQRSTUVWXYZ')
> SBeep(nPos,9,'WAV')
> ENDIF
>
> TBarCode->(OrdSetFocus(1))
> TBarList->(OrdSetFocus(1))
> ENDIF
>
>
>
>
>
> On 18/06/2013 11:59, Ginny Caughey wrote:
>> If you access DBF files, don't share the workarea with any other thread.
>> Use normal multiuser access patterns.
>> No dynamic data types such as strings that might trigger garbage
>> collection.
>> Seriously consider why this needs to be a separate thread instead of a
>> separate app.
>>
>> HTH,
>> Ginny
>>
>> "Martin" wrote in message news:WKWvt.136194$I84.63382@fx07.fr7...
>>
>> Got quite a bit on the go now, but need a thread with data access, also
>> it may need to run continually.
>>
>> Anything I need to be careful with please?
>>
>> Tahnks
>>
>> Martin
>
Back to comp.lang.clipper.visual-objects | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Thread safe code - any caveats? Martin <spam@spam.spam> - 2013-06-18 11:36 +0100
Re: Thread safe code - any caveats? "Ginny Caughey" <gcaughey@online.hotmail.com> - 2013-06-18 06:59 -0400
Re: Thread safe code - any caveats? Martin <spam@spam.spam> - 2013-06-18 12:05 +0100
Re: Thread safe code - any caveats? "Ginny Caughey" <gcaughey@online.hotmail.com> - 2013-06-18 12:41 -0400
Re: Thread safe code - any caveats? Martin <spam@spam.spam> - 2013-06-19 09:14 +0100
Re: Thread safe code - any caveats? "Ginny Caughey" <gcaughey@online.hotmail.com> - 2013-06-19 07:24 -0400
Re: Thread safe code - any caveats? Martin <spam@spam.spam> - 2013-06-19 12:40 +0100
Re: Thread safe code - any caveats? "Ginny Caughey" <gcaughey@online.hotmail.com> - 2013-06-19 10:02 -0400
Re: Thread safe code - any caveats? Martin <spam@spam.spam> - 2013-06-19 17:07 +0100
Re: Thread safe code - any caveats? "Ginny Caughey" <gcaughey@online.hotmail.com> - 2013-06-20 07:22 -0400
Re: Thread safe code - any caveats? Martin <spam@spam.spam> - 2013-06-20 17:12 +0100
Re: Thread safe code - any caveats? "Ginny Caughey" <gcaughey@online.hotmail.com> - 2013-06-20 14:04 -0400
Re: Thread safe code - any caveats? "Martin \(BT\)" <martin-spam@btinternet.com> - 2013-06-20 20:27 +0100
Re: Thread safe code - any caveats? "Ginny Caughey" <gcaughey@online.hotmail.com> - 2013-06-21 06:54 -0400
Re: Thread safe code - any caveats? Martin <spam@spam.spam> - 2013-06-21 15:39 +0100
Re: Thread safe code - any caveats? Martin <spam@spam.spam> - 2013-06-21 15:54 +0100
Re: Thread safe code - any caveats? "Ginny Caughey" <gcaughey@online.hotmail.com> - 2013-06-21 12:12 -0400
Re: Thread safe code - any caveats? Martin <spam@spam.spam> - 2013-06-21 17:15 +0100
Re: Thread safe code - any caveats? dlzc <dlzc1@cox.net> - 2013-06-19 08:04 -0700
Re: Thread safe code - any caveats? Martin <spam@spam.spam> - 2013-06-19 17:04 +0100
csiph-web