[futurebasic] Re: When to dispose of Hndl& and Ptr&?

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : December 1997 : Group Archive : Group : All Groups

From: ars@... (morethanone)
Date: Sat, 6 Dec 1997 09:16:36 -0800
> Thank you for the generous replies on what is a difficult concept for me.

I also really appreciate all the insight into handling handles. I have a
related question about when to HLOCK and HUNLOCK.

I'm using an ENTERPROC% routine that passes a long input string to my
function, which creates a handle to a new long output string. Thinking
that I was following the manual's advice "Don't leave handles locked!",
I locked the output string just after I created it, then unlocked it
just before I handed it back to the caller.

Sometimes this worked, sometimes it didn't. A couple of days ago, I went
back to the manual and this time got a different take. I decided I'd
better emulate the nearby example code, putting lock/unlock calls around
each section of code that used the handle. 

That did it... the problem went away.  I guess the question is, is there
some way to decide how often to lock/unlock? Every time you use the
handle, because there's no way of knowing when a handle will need to
"float"? Just when the code might change the size of the data?

-- Tony
<http://www.oz.net/~ars/> NF MIDI Rock Mac