Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Critical Section in VFP
Message
From
05/07/2000 17:23:31
 
 
To
05/07/2000 16:59:57
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00387913
Message ID:
00388559
Views:
13
>>While this works in this instance, I'd recommend using a static memory block allocation as a general approach, to avoid having VFP shift the structure around in memory. CLSHEAP can create a heap and alocate space on it that VFP won't mess with directly, nd you can form structures in a string and copy them between the static block and normal VFP memvars using the methods from the class, or the UDFs that accompany it. It uses RtlMoveMemory() to handle the transfers between the static block and VFP memvars, so no add-on .DLLs or controls are needed.
>>
>>>+++ Rick ---
>>>
>>>
>>>>>>We need to have a multi-use com server but need to place a critical section in one area of the code which we do not want the multiple instances to trample on each other.
>>>>>
>>>>>There's a new undocumented (though Calvin demoed it last year, so I guess that means I can talk about it :-) SYS function in SP3 that deals with this, SYS(2336). IIRC, the parameters are 1 to start a CS, and 0 to end it.
>>>>
>>>>
>>>>That's great. Are there any changes from 6 to 7 other than the documentation? BTW, what is the default, if you don't pass a parameter?
>
>I was wondering when you were going to chime in. :) I like the idea of using CLSHEAP for the reasons you have given. Are there any examples of using CLSHEAP with critical sections that you can point me to?

No; I'd advise reading up on the use of the Critical Section APIs in Richter's "Advanced Windows"; there's extensive C code demonstrating several mechanisms that can be used to implement critical sections in it, and you can simply use CLSHEAP to allocate the memory used for the structures - it's necessary whenever an embedded pointer is involved, since VFP's strings can be moved around within the address space, and moving the string makes any pointer to it invalid, although pointers to other things stored in the moved string will remain valid if the thing being pointed to doesn't move.
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform