Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Two datasessions in a form, part II
Message
De
19/01/2006 13:23:51
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
 
 
À
19/01/2006 12:47:57
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows 2000 SP4
Database:
MS SQL Server
Divers
Thread ID:
01088058
Message ID:
01088553
Vues:
10
>>>>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.
>
>???? same parent ???
>two objects with same "parent" property cannot live in separate datasessions.

Same parent class - i.e. they are defined as classes derived from the same class. And the code makes sure they have separate DSes.

>>
*-- pSession is just a session object with private ds
>>o=Createobject("psession")
>>this.AddProperty("oDS2",o)
>* this is a terrible operation !!!!!
>>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
>
>this raiseevent() doesn't activate oform

But then does form.activate() do that? Or do I need to set focus to something on it?

>>
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.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform