Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Two datasessions in a form, part II
Message
From
19/01/2006 11:58:21
Dragan Nedeljkovich
Now officially retired
Zrenjanin, Serbia
 
 
To
18/01/2006 15:43:22
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows 2000 SP4
Database:
MS SQL Server
Miscellaneous
Thread ID:
01088058
Message ID:
01088486
Views:
11
>>But this object was created in DS 1, during the app start, before any new DS was created (no forms run yet, no session objects created). And it executes in any DS, which is the weird part, and then after a few calls it executes in a wrong DS, which is even weirder.
>>
>>And some other global objects, created at the same time, consistently execute in DS 1. Can't catch any logic here.
>
>can you extract a repro. I don't look it

Too long, but here's the scenario:

- have one object assigned to a public variable, which has a method which does scan/end in the current cursor. It may just return a count.

- another object is a prg-based bizobject (let's call it oBz1), instantiated in a form's .load(). The form has a private datasession. This object creates two cursors.

- in the .init of this instantiate oBz2, and assign it to a property of obz1. Obz2 creates two cursors with the same name as those of obz1, but with a different structure. Obz2 lives in a separate DS, and has the same parent class as obz1.
*-- pSession is just a session object with private ds
o=Createobject("psession")
this.AddProperty("oDS2",o)
Set DataSession To (.oDS2.DataSessionId)
loBz2=Createobject("bz2")
this.AddProperty("obz2",loBz2)
set datasession to this.nDataSession
Now run a few methods in obz1 and have them call methods from this.obz2, and watch for the datasession. Also call some methods from the global object. What I have observed is that after a while the datasession doesn't switch back after return (it remains DS 3 when returning to obz1, or remains DS2 after repeatedly calling a method in .obz2).

More weirdness: wrap this in a transaction, and also have .obz2 have its own transaction. If you watch txnlevel(), it will be zero while running code in the global object (in DS 1), but will stay more or less what you expect it while running code in obz1 and .obz2... until at some point it loses one level when returning to obz1.

A possible cause for some of this may be the two grids I have on the form, and they may refresh at random intervals (even though form.lockscreen=.t.), which may be the cause of DS switching to 2 while executing code in DS 3. To prevent that, I've actually instantiated the form to which obz2 usually belongs, like this:
oFrmA=Createobject("frm2")
this.AddProperty("oFrm2", oFrmA)
this.oFrm2.Top=_Screen.Height*3
this.oFrm2.Show(2)
this.AddProperty("obz2", this.oFrm2.obz)
and whenever I return from a method in the other obz, I issue a
raiseevent(this.oForm, "activate")
set datasession to this.nDatasession
and that seems to have fixed it. At least the grid refreshes in the other form aren't selecting wrong aliases in wrong datasession.

And I had to separate the calls into separate transactions, i.e. when the code in obz1 runs in a transaction, no transaction is active in obz2 and vice versa. Originally, I had two or three transaction levels, where only the outer level was started in obz1, and the rest were in obz2. VFP seems not to like this at all.

Works now, but if you feel like digging deeper into this, be my guest.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform