Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Single use instancing isn't single?
Message
From
04/03/2004 10:31:44
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Title:
Single use instancing isn't single?
Miscellaneous
Thread ID:
00883104
Message ID:
00883104
Views:
74
I have the following experience:

After putting the following prg into a project (test.pjx) and setting the COM servers instacing to "single use" I would expect to have 4 different process ID's.
But there are only 3, it looks like the two objects created via COM share the same process. Even more strange is that they are created by two different processes.

Further investigation shows that they are really sharing the same VFP instance, e.g. fiddling with some public variables affects both objects.

Am I doing something wrong?

---test.prg--------------------------
#Define HomeDir 'c:\temp\5\'

*****************
*ALGO:
* 1. "runsvc" - run test.exe which creates the service object,
* 2. "service" - and runs the service
* 3. "runtask" - the service executes "test.exe x" which should be a task
* 4. "task" - now test.exe creates the task object, which executes the task
*
* before each point the process ID is written to a file with the given ID
* as the server instancing for Task and Service is set to "SINGLE"
* I would expect the there will be 4 DIFFERENT PID's,
* but there are only 3 different one's
*****************

Lparameters tcPar1

Set Resource Off

If Pcount()=0
writepid('runsvc', _vfp.ProcessID)

Local x
x=Createobjectex('test.Service','')
x.wr_pid()
x.Run()
x=.Null.
Else
writepid('runtask', _vfp.ProcessID)

Local x,Y
x=Createobjectex('test.Task','')
x.wr_pid()

*uncomment the lines below to get one more DIFFERENT PID
*y=CreateObject('test.Task')
*y.wr_pid()

x.Run()
x=.Null.
Endif

Define Class Task As Relation OlePublic

Procedure wr_pid
writepid(This.Class, _vfp.ProcessID)

Procedure Run
Do pretend_doing_sg
Enddefine

Define Class Service As Task OlePublic

Procedure Run
Declare Integer ShellExecute In shell32.Dll Integer hndWin, ;
STRING cAction, String cFileName, String cParams, String cDir, ;
INTEGER nShowWin

lcFileName = HomeDir+"test.exe"
lcAction = "open"
lcDir = ''
lcPar = 'x'

=ShellExecute(_vfp.hWnd, lcAction, lcFileName, lcPar, lcDir, 0)

Do pretend_doing_sg

Enddefine

Procedure writepid
Lparameters tcPar, tnPid
Strtofile(tcPar+Str(tnPid,10)+Chr(13)+Chr(10), HomeDir+'pidlog.txt',1)
*StrToFile(lcFileName+ ' '+tcPar+Str(tnPid,10)+Chr(13)+Chr(10), HOMEDIR+'pidlog.txt',1)

Procedure pretend_doing_sg
lnDurationsec=Seconds()
Do While Seconds() < lnDurationsec+5
Enddo

---pidlog.txt---------------
runsvc 2384
Service 1256
runtask 2524
Task 1256
Next
Reply
Map
View

Click here to load this message in the networking platform