If it's an object that maintains state, then there's no problem.  If it's a
stateless COM+ component, then no.  I do recommend ditching the Intit
method and initializing the property values in the constructor call :

Dim objMyObject as New TransactionalObject(x,y,z) . . .etc.

IIRC, the Init functions evolved from VB classes not supporting
parameterized constructors.

Of course, if you're not talking .NET, then VB6 will not allow
parameterized constructors.  Which  . . . reading through the thread, you
probably are, so ignore everything . . .

Steve Holak
Senior Software Architect

Brokerage Concepts IS Dept.
610-491-4879

email:  [EMAIL PROTECTED]



                    Alan Williams
                    <Alan.Williams@RTI        To:     [EMAIL PROTECTED]
                    X.CO.UK>                  cc:
                    Sent by: dotnet           Subject:     Re: [DOTNET] Serviced 
Components and New()
                    discussion
                    <[EMAIL PROTECTED]
                    VELOP.COM>


                    04/18/2002 12:10
                    PM
                    Please respond to
                    dotnet discussion






Could you try to clarify something for me, Peter.

I will create a New() object.
I will then call Init() on that object to set some properties. Init()
will DisableCommit to keep the object active after the Init() returns
(Done bit = false).
I will then call a transactional method that uses the connection string
property.
This method will write to the database and then SetComplete() or
SetAbort() to commit or abort the transaction. This will set the Done
bit = true ... and the object will deactivate(?)

Can I then call another method (possibly the same method) on the object
without having to instantiate and initialise it again? I am thinking of
something like ...

Dim objMyObject as New TransactionalObject()
objMyObject.Init(x,y,z)
For c = 1 TO n
        objMyObject.TransactionalMethod(.. , .. , ..)
Next


Thanks

Alan

-----Original Message-----
From: Peter Foreman [mailto:[EMAIL PROTECTED]]
Sent: 18 April 2002 16:40
To: [EMAIL PROTECTED]
Subject: Re: [DOTNET] Serviced Components and New()


[EMAIL PROTECTED]
[EMAIL PROTECTED]

--- Alan Williams <[EMAIL PROTECTED]> wrote:
> But could you tell me why I should DisableCommit for JIT activated
> objects.

I should really have said for transactional components.  (Since you are
using transactions you are
also using JIT activation implicitly).  You'll never want to commit a
transaction after just an
Init call, presumably you'll also have some other work to do, so to mark
this it would be best to
call IObjectControl::DisableCommit.  If you don't then the component is
saying 'I'm happy to
commit this transaction' (by default - EnableCommit) when it returns
from Init.

You definitely don't want to call SetComplete or SetAbort in Init which
would allow COM+ to
deactivate your component and lose its state between method calls.
These should only be called
after your real work is complete for the object.

Peter


__________________________________________________
Do You Yahoo!?
Yahoo! Tax Center - online filing with TurboTax
http://taxes.yahoo.com/

You can read messages from the DOTNET archive, unsubscribe from DOTNET,
or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to