You don't have to create a new object but it will need to be initialized
again.

When your transaction commits/aborts, the COM+ runtime deactivates your
object (basically either destroys or pools it). When you make a
subsequent method call, the COM+ runtime automatically creates a "new"
object (either by instantiation or grabs one from the pool). This object
will generally be in its initial (just instantiated state). So, in your
example, you'll have to call Init again.

-- Brent Rector, .NET Wise Owl
Demeanor for .NET - an obfuscation utility
http://www.wiseowl.com/Products/Products.aspx



-----Original Message-----
From: Alan Williams [mailto:[EMAIL PROTECTED]] 
Sent: Thursday, April 18, 2002 9:10 AM
To: [EMAIL PROTECTED]
Subject: Re: [DOTNET] Serviced Components and New()


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