I have a VB application that is spawning off multiple VFP tasks using a
multi threaded VFP COM DLL I have created.

The code is something like this:

oTest1 = CREATEOBJECT("foxole.person")
oTest2 = CREATEOBJECT("foxole.person")

(This is not the real syntax but gives you an idea)

There could be a varied number of objects created from 1 to many.

This seems to work fine except that the 2 objects seem to share certain
elements.

Changing a record in a table in one object changes it in the other, setting
fiters in one sets the filter in the other, closing a table in one closes it
in the other etc.

What I want is for the 2 objects to run in completely separate memory
spaces.

I have created a multi-threaded DLL and my Project Server tab has the
classes set to Single Use instancing.

How can I ensure that the 2 objects oTest1 and oTest2 run in completely
separate memry spaces with no interraction between them at all?

Cheers
David Younger

RE: Multithreaded COM DLL by turiya36

turiya36
Sun Apr 18 20:21:01 CDT 2004

What version of VFP are you using?

Re: Multithreaded COM DLL by David

David
Mon Apr 19 00:39:59 CDT 2004

VFP8
"turiya36" <turiya36@yahoo.com> wrote in message
news:5CE8AE26-891E-4433-B981-D244DE485273@microsoft.com...
> What version of VFP are you using?



Re: Multithreaded COM DLL by Villi

Villi
Mon Apr 19 02:51:14 CDT 2004

David Younger wrote:

> What I want is for the 2 objects to run in completely
> separate memory spaces.
>
> I have created a multi-threaded DLL and my Project Server
> tab has the classes set to Single Use instancing.
>
> How can I ensure that the 2 objects oTest1 and oTest2 run
> in completely separate memry spaces with no interraction
> between them at all?

It seems that if you create an EXE or a DLL you will obtain
different behavior. From the VFP8 guide ("index" ->
"multithreaded programs") :
SingleUse Objects in EXE Servers
With the Instancing property set to SingleUse, each instance
causes a new EXE process to begin (under Windows NT 4.0 or later
you will see each running process in the Task Manager). With the
MultiUse setting, the first instance will cause a new process to
start, but each new object instance shares the same process as
the first.

SingleUse Objects in DLL Servers
The Instancing property is ignored for multithreaded .dlls and is
only read for the Vfp8r.dll run time. Servers built for use with
the vfp8t.dll library are always MultiUse regardless of their
setting. In general, you should always set the Instancing
property to MultiUse for vfp8r.dll in-process servers. If you set
it to SingleUse, only one instance of an object from that server
can be created. You will get an error if you try to instantiate
more objects. Only under rare circumstances would you want to use
the SingleUse setting. In fact, Microsoft Transaction Server
components require the MultiUse setting. SingleUse objects often
require more memory overhead than multiple objects in a
multithreaded component.



Chech you situation regarding these issues.

HTH
Vilco



Re: Multithreaded COM DLL by Craig

Craig
Mon Apr 19 10:05:16 CDT 2004

What base class was used to create the VFP COM object? You should be using
the Session Class as it will give private data sessions...and that will give
you the behavior you desire.

--
Craig Berntson
MCSD, Visual FoxPro MVP
Author, CrysDev: A Developer's Guide to Integrating Crystal Reports
www.craigberntson.com
email iamcraig@craigberntson.com (remove iam)
Salt Lake City Fox User Group
www.slcfox.org


"David Younger" <david@ATproware.com.au> wrote in message
news:OeycEAaJEHA.2652@TK2MSFTNGP12.phx.gbl...
> I have a VB application that is spawning off multiple VFP tasks using a
> multi threaded VFP COM DLL I have created.
>
> The code is something like this:
>
> oTest1 = CREATEOBJECT("foxole.person")
> oTest2 = CREATEOBJECT("foxole.person")
>
> (This is not the real syntax but gives you an idea)
>
> There could be a varied number of objects created from 1 to many.
>
> This seems to work fine except that the 2 objects seem to share certain
> elements.
>
> Changing a record in a table in one object changes it in the other,
setting
> fiters in one sets the filter in the other, closing a table in one closes
it
> in the other etc.
>
> What I want is for the 2 objects to run in completely separate memory
> spaces.
>
> I have created a multi-threaded DLL and my Project Server tab has the
> classes set to Single Use instancing.
>
> How can I ensure that the 2 objects oTest1 and oTest2 run in completely
> separate memry spaces with no interraction between them at all?
>
> Cheers
> David Younger
>
>



Re: Multithreaded COM DLL by David

David
Tue Apr 20 21:43:35 CDT 2004

Thank you Craig - I was not aware of the Session Class!

The base class is the Custom Class.

I have looked at the documentation and can understand how to invoke this
session class from within a VFP application program but am a bit confused as
to how to implement it from my VB Application.

Could you please provide an example of how to do this so that all methods
within the Com Object are in a private session.

Cheers
David


"Craig Berntson" <iamcraig@craigberntson.com> wrote in message
news:eHyTL%23hJEHA.1392@TK2MSFTNGP09.phx.gbl...
> What base class was used to create the VFP COM object? You should be using
> the Session Class as it will give private data sessions...and that will
give
> you the behavior you desire.
>
> --
> Craig Berntson
> MCSD, Visual FoxPro MVP
> Author, CrysDev: A Developer's Guide to Integrating Crystal Reports
> www.craigberntson.com
> email iamcraig@craigberntson.com (remove iam)
> Salt Lake City Fox User Group
> www.slcfox.org
>
>
> "David Younger" <david@ATproware.com.au> wrote in message
> news:OeycEAaJEHA.2652@TK2MSFTNGP12.phx.gbl...
> > I have a VB application that is spawning off multiple VFP tasks using a
> > multi threaded VFP COM DLL I have created.
> >
> > The code is something like this:
> >
> > oTest1 = CREATEOBJECT("foxole.person")
> > oTest2 = CREATEOBJECT("foxole.person")
> >
> > (This is not the real syntax but gives you an idea)
> >
> > There could be a varied number of objects created from 1 to many.
> >
> > This seems to work fine except that the 2 objects seem to share certain
> > elements.
> >
> > Changing a record in a table in one object changes it in the other,
> setting
> > fiters in one sets the filter in the other, closing a table in one
closes
> it
> > in the other etc.
> >
> > What I want is for the 2 objects to run in completely separate memory
> > spaces.
> >
> > I have created a multi-threaded DLL and my Project Server tab has the
> > classes set to Single Use instancing.
> >
> > How can I ensure that the 2 objects oTest1 and oTest2 run in completely
> > separate memry spaces with no interraction between them at all?
> >
> > Cheers
> > David Younger
> >
> >
>
>



Re: Multithreaded COM DLL by Craig

Craig
Wed Apr 21 10:14:46 CDT 2004

DEFINE CLASS MyClass AS Session OLEPUBLIC

MyProperty1 = "String"
MyProperty2 = 12

PROCEDURE MyProc1
* Code goes here*
RETURN SomeValue
ENDPROC

PROCEDURE MyProc2
LPARAMETERS Param1, Param2

*Code goes here
ENDPROC

ENDDEFINE

Then compile the code into a DLL

You will then invoke it just as you previously had.
--
Craig Berntson
MCSD, Visual FoxPro MVP
Author, CrysDev: A Developer's Guide to Integrating Crystal Reports
www.craigberntson.com
email iamcraig@craigberntson.com (remove iam)
Salt Lake City Fox User Group
www.slcfox.org


"David Younger" <david@ATproware.com.au> wrote in message
news:eCAcfq0JEHA.1760@TK2MSFTNGP10.phx.gbl...
> Thank you Craig - I was not aware of the Session Class!
>
> The base class is the Custom Class.
>
> I have looked at the documentation and can understand how to invoke this
> session class from within a VFP application program but am a bit confused
as
> to how to implement it from my VB Application.
>
> Could you please provide an example of how to do this so that all methods
> within the Com Object are in a private session.
>
> Cheers
> David
>
>
> "Craig Berntson" <iamcraig@craigberntson.com> wrote in message
> news:eHyTL%23hJEHA.1392@TK2MSFTNGP09.phx.gbl...
> > What base class was used to create the VFP COM object? You should be
using
> > the Session Class as it will give private data sessions...and that will
> give
> > you the behavior you desire.
> >
> > --
> > Craig Berntson
> > MCSD, Visual FoxPro MVP
> > Author, CrysDev: A Developer's Guide to Integrating Crystal Reports
> > www.craigberntson.com
> > email iamcraig@craigberntson.com (remove iam)
> > Salt Lake City Fox User Group
> > www.slcfox.org
> >
> >
> > "David Younger" <david@ATproware.com.au> wrote in message
> > news:OeycEAaJEHA.2652@TK2MSFTNGP12.phx.gbl...
> > > I have a VB application that is spawning off multiple VFP tasks using
a
> > > multi threaded VFP COM DLL I have created.
> > >
> > > The code is something like this:
> > >
> > > oTest1 = CREATEOBJECT("foxole.person")
> > > oTest2 = CREATEOBJECT("foxole.person")
> > >
> > > (This is not the real syntax but gives you an idea)
> > >
> > > There could be a varied number of objects created from 1 to many.
> > >
> > > This seems to work fine except that the 2 objects seem to share
certain
> > > elements.
> > >
> > > Changing a record in a table in one object changes it in the other,
> > setting
> > > fiters in one sets the filter in the other, closing a table in one
> closes
> > it
> > > in the other etc.
> > >
> > > What I want is for the 2 objects to run in completely separate memory
> > > spaces.
> > >
> > > I have created a multi-threaded DLL and my Project Server tab has the
> > > classes set to Single Use instancing.
> > >
> > > How can I ensure that the 2 objects oTest1 and oTest2 run in
completely
> > > separate memry spaces with no interraction between them at all?
> > >
> > > Cheers
> > > David Younger
> > >
> > >
> >
> >
>
>



Re: Multithreaded COM DLL by David

David
Wed Apr 21 21:41:31 CDT 2004

Thanx Craig.

In my case, the procedures are already included in an OlePublic custom class
in a .VCX file. This class is very large and has been developed over a long
period of time.

How would I incorporate this class into the session?

Cheers
David


"Craig Berntson" <iamcraig@craigberntson.com> wrote in message
news:OBS%23tM7JEHA.644@tk2msftngp13.phx.gbl...
> DEFINE CLASS MyClass AS Session OLEPUBLIC
>
> MyProperty1 = "String"
> MyProperty2 = 12
>
> PROCEDURE MyProc1
> * Code goes here*
> RETURN SomeValue
> ENDPROC
>
> PROCEDURE MyProc2
> LPARAMETERS Param1, Param2
>
> *Code goes here
> ENDPROC
>
> ENDDEFINE
>
> Then compile the code into a DLL
>
> You will then invoke it just as you previously had.
> --
> Craig Berntson
> MCSD, Visual FoxPro MVP
> Author, CrysDev: A Developer's Guide to Integrating Crystal Reports
> www.craigberntson.com
> email iamcraig@craigberntson.com (remove iam)
> Salt Lake City Fox User Group
> www.slcfox.org
>
>
> "David Younger" <david@ATproware.com.au> wrote in message
> news:eCAcfq0JEHA.1760@TK2MSFTNGP10.phx.gbl...
> > Thank you Craig - I was not aware of the Session Class!
> >
> > The base class is the Custom Class.
> >
> > I have looked at the documentation and can understand how to invoke this
> > session class from within a VFP application program but am a bit
confused
> as
> > to how to implement it from my VB Application.
> >
> > Could you please provide an example of how to do this so that all
methods
> > within the Com Object are in a private session.
> >
> > Cheers
> > David
> >
> >
> > "Craig Berntson" <iamcraig@craigberntson.com> wrote in message
> > news:eHyTL%23hJEHA.1392@TK2MSFTNGP09.phx.gbl...
> > > What base class was used to create the VFP COM object? You should be
> using
> > > the Session Class as it will give private data sessions...and that
will
> > give
> > > you the behavior you desire.
> > >
> > > --
> > > Craig Berntson
> > > MCSD, Visual FoxPro MVP
> > > Author, CrysDev: A Developer's Guide to Integrating Crystal Reports
> > > www.craigberntson.com
> > > email iamcraig@craigberntson.com (remove iam)
> > > Salt Lake City Fox User Group
> > > www.slcfox.org
> > >
> > >
> > > "David Younger" <david@ATproware.com.au> wrote in message
> > > news:OeycEAaJEHA.2652@TK2MSFTNGP12.phx.gbl...
> > > > I have a VB application that is spawning off multiple VFP tasks
using
> a
> > > > multi threaded VFP COM DLL I have created.
> > > >
> > > > The code is something like this:
> > > >
> > > > oTest1 = CREATEOBJECT("foxole.person")
> > > > oTest2 = CREATEOBJECT("foxole.person")
> > > >
> > > > (This is not the real syntax but gives you an idea)
> > > >
> > > > There could be a varied number of objects created from 1 to many.
> > > >
> > > > This seems to work fine except that the 2 objects seem to share
> certain
> > > > elements.
> > > >
> > > > Changing a record in a table in one object changes it in the other,
> > > setting
> > > > fiters in one sets the filter in the other, closing a table in one
> > closes
> > > it
> > > > in the other etc.
> > > >
> > > > What I want is for the 2 objects to run in completely separate
memory
> > > > spaces.
> > > >
> > > > I have created a multi-threaded DLL and my Project Server tab has
the
> > > > classes set to Single Use instancing.
> > > >
> > > > How can I ensure that the 2 objects oTest1 and oTest2 run in
> completely
> > > > separate memry spaces with no interraction between them at all?
> > > >
> > > > Cheers
> > > > David Younger
> > > >
> > > >
> > >
> > >
> >
> >
>
>



Re: Multithreaded COM DLL by Craig

Craig
Thu Apr 22 10:24:55 CDT 2004

You'll need to copy and paste the code from the custom class into the
session class.

--
Craig Berntson
MCSD, Visual FoxPro MVP
Author, CrysDev: A Developer's Guide to Integrating Crystal Reports
www.craigberntson.com
email iamcraig@craigberntson.com (remove iam)
Salt Lake City Fox User Group
www.slcfox.org


"David Younger" <david@ATproware.com.au> wrote in message
news:OYlCAOBKEHA.2556@TK2MSFTNGP11.phx.gbl...
> Thanx Craig.
>
> In my case, the procedures are already included in an OlePublic custom
class
> in a .VCX file. This class is very large and has been developed over a
long
> period of time.
>
> How would I incorporate this class into the session?
>
> Cheers
> David
>
>
> "Craig Berntson" <iamcraig@craigberntson.com> wrote in message
> news:OBS%23tM7JEHA.644@tk2msftngp13.phx.gbl...
> > DEFINE CLASS MyClass AS Session OLEPUBLIC
> >
> > MyProperty1 = "String"
> > MyProperty2 = 12
> >
> > PROCEDURE MyProc1
> > * Code goes here*
> > RETURN SomeValue
> > ENDPROC
> >
> > PROCEDURE MyProc2
> > LPARAMETERS Param1, Param2
> >
> > *Code goes here
> > ENDPROC
> >
> > ENDDEFINE
> >
> > Then compile the code into a DLL
> >
> > You will then invoke it just as you previously had.
> > --
> > Craig Berntson
> > MCSD, Visual FoxPro MVP
> > Author, CrysDev: A Developer's Guide to Integrating Crystal Reports
> > www.craigberntson.com
> > email iamcraig@craigberntson.com (remove iam)
> > Salt Lake City Fox User Group
> > www.slcfox.org
> >
> >
> > "David Younger" <david@ATproware.com.au> wrote in message
> > news:eCAcfq0JEHA.1760@TK2MSFTNGP10.phx.gbl...
> > > Thank you Craig - I was not aware of the Session Class!
> > >
> > > The base class is the Custom Class.
> > >
> > > I have looked at the documentation and can understand how to invoke
this
> > > session class from within a VFP application program but am a bit
> confused
> > as
> > > to how to implement it from my VB Application.
> > >
> > > Could you please provide an example of how to do this so that all
> methods
> > > within the Com Object are in a private session.
> > >
> > > Cheers
> > > David
> > >
> > >
> > > "Craig Berntson" <iamcraig@craigberntson.com> wrote in message
> > > news:eHyTL%23hJEHA.1392@TK2MSFTNGP09.phx.gbl...
> > > > What base class was used to create the VFP COM object? You should be
> > using
> > > > the Session Class as it will give private data sessions...and that
> will
> > > give
> > > > you the behavior you desire.
> > > >
> > > > --
> > > > Craig Berntson
> > > > MCSD, Visual FoxPro MVP
> > > > Author, CrysDev: A Developer's Guide to Integrating Crystal Reports
> > > > www.craigberntson.com
> > > > email iamcraig@craigberntson.com (remove iam)
> > > > Salt Lake City Fox User Group
> > > > www.slcfox.org
> > > >
> > > >
> > > > "David Younger" <david@ATproware.com.au> wrote in message
> > > > news:OeycEAaJEHA.2652@TK2MSFTNGP12.phx.gbl...
> > > > > I have a VB application that is spawning off multiple VFP tasks
> using
> > a
> > > > > multi threaded VFP COM DLL I have created.
> > > > >
> > > > > The code is something like this:
> > > > >
> > > > > oTest1 = CREATEOBJECT("foxole.person")
> > > > > oTest2 = CREATEOBJECT("foxole.person")
> > > > >
> > > > > (This is not the real syntax but gives you an idea)
> > > > >
> > > > > There could be a varied number of objects created from 1 to many.
> > > > >
> > > > > This seems to work fine except that the 2 objects seem to share
> > certain
> > > > > elements.
> > > > >
> > > > > Changing a record in a table in one object changes it in the
other,
> > > > setting
> > > > > fiters in one sets the filter in the other, closing a table in one
> > > closes
> > > > it
> > > > > in the other etc.
> > > > >
> > > > > What I want is for the 2 objects to run in completely separate
> memory
> > > > > spaces.
> > > > >
> > > > > I have created a multi-threaded DLL and my Project Server tab has
> the
> > > > > classes set to Single Use instancing.
> > > > >
> > > > > How can I ensure that the 2 objects oTest1 and oTest2 run in
> > completely
> > > > > separate memry spaces with no interraction between them at all?
> > > > >
> > > > > Cheers
> > > > > David Younger
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>



Re: Multithreaded COM DLL by Claude

Claude
Wed Jun 16 17:53:01 CDT 2004

In addition to using the Session class that Craig mentioned, make sure you
set Server Instancing to Multi-use for vfp mtdlls. Setting instancing to
single-use is a huge memory drain in mtdlls and is not necessary...
"David Younger" <david@ATproware.com.au> wrote in message
news:OeycEAaJEHA.2652@TK2MSFTNGP12.phx.gbl...
> I have a VB application that is spawning off multiple VFP tasks using a
> multi threaded VFP COM DLL I have created.
>
> The code is something like this:
>
> oTest1 = CREATEOBJECT("foxole.person")
> oTest2 = CREATEOBJECT("foxole.person")
>
> (This is not the real syntax but gives you an idea)
>
> There could be a varied number of objects created from 1 to many.
>
> This seems to work fine except that the 2 objects seem to share certain
> elements.
>
> Changing a record in a table in one object changes it in the other,
setting
> fiters in one sets the filter in the other, closing a table in one closes
it
> in the other etc.
>
> What I want is for the 2 objects to run in completely separate memory
> spaces.
>
> I have created a multi-threaded DLL and my Project Server tab has the
> classes set to Single Use instancing.
>
> How can I ensure that the 2 objects oTest1 and oTest2 run in completely
> separate memry spaces with no interraction between them at all?
>
> Cheers
> David Younger
>
>