Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / July 2005

Tip: Looking for answers? Try searching our database.

How to know whether a serviced component comes from a pool or not

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Juan Dent - 16 Jul 2005 00:06 GMT
Hi,

For debugging purposes, it may be useful to know whether an object that has
been constructed from a client (via a new XX) is going to come from a pool
(assuming pooling is enabled for that serviced component) or not.

All I have been able to find is ServicedComponent.Activate which is virtual.
However this does not give me any info regarding whether it is a new object
or comes from a pool!

Am I missing something here?
Signature

Thanks in advance,

Juan Dent, M.Sc.

Willy Denoyette [MVP] - 16 Jul 2005 08:22 GMT
> Hi,
>
[quoted text clipped - 10 lines]
>
> Am I missing something here?

You have to override Activate(), whenever it's called you know that it's
instance is taken from the pool.

protected override  void Activate() {
   // He! I'm a pooled instance.
   // do some specific processing when activated from the pool.
}

Same goes for CanBePooled and Deactivate, you should override these if you
need to perform some special processing when called.
So, CanBePooled should return true if you want this instance to return to
the pool.
Deactivate is called when the instance returns to the pool.
Another overridable is Construct, this gets called whenever a 'fresh'
instance is created.

Willy.
Juan Dent - 16 Jul 2005 22:11 GMT
A slight correction if I may:

--protected override  void Activate() {
--    // He! I'm a pooled instance.
--    // do some specific processing when activated from the pool.
--}

If the class is not pooled but has JITA enabled, then Activate gets called
upon activation, not because it is being taken out of the pool.

Also, I don't see this behavior either if the component is pooled or JITA or
both:

--Another overridable is Construct, this gets called whenever a 'fresh'
--instance is created.

My assumption is that Construct will be called ONLY when Construction is
enabled via attributes or the CSE.

Is this correct?

Signature

Thanks in advance,

Juan Dent, M.Sc.

> > Hi,
> >
[quoted text clipped - 28 lines]
>
> Willy.
Willy Denoyette [MVP] - 17 Jul 2005 20:55 GMT
Inline

Willy.

>A slight correction if I may:
>
[quoted text clipped - 5 lines]
> If the class is not pooled but has JITA enabled, then Activate gets called
> upon activation, not because it is being taken out of the pool.

No, Activate is called whenever the object is taken from the pool.
'Deactivate' when an "activated" object gets released.

> Also, I don't see this behavior either if the component is pooled or JITA
> or
> both:

You must have 'Component supports events and statistics' enabled.
> --Another overridable is Construct, this gets called whenever a 'fresh'
> --instance is created.
[quoted text clipped - 3 lines]
>
> Is this correct?

Yep, "Construct" is called when the Object Construction is enabled, but only
when a fresh instance is created, NOT when the object is taken from the
pool.
The same goes for the objects contructor, it's only called when a new
instance is created, NOT whe taken from the pool.
.
.

>> > Hi,
>> >
[quoted text clipped - 30 lines]
>>
>> Willy.
Juan Dent - 18 Jul 2005 20:04 GMT
An example I have shows that Activate() is called not only when pooling is
enabled and the object is taken from the pool, but EVEN in the abscence of
pooling, if JITA is enabled, then Activate()/Deactivate() are called each
time the object is activated/deactivated...

Thus we have a contradiction or we differ in some other setting. ??
Signature

Thanks in advance,

Juan Dent, M.Sc.

> Inline
>
[quoted text clipped - 68 lines]
> >>
> >> Willy.
Willy Denoyette [MVP] - 18 Jul 2005 21:38 GMT
Well, I didn't say it's not called in a JITA scenario, I said it's called
when an instance is taken from the pool even when JITA is not enabled.
Both JITA and Pooling are different concepts, but they can, and are mostly
used in tandem.
Note that both JITA and pooling have different semantics, a pooled non-JITA
object is activated when the client creates an instance, a JITA (pooled or
not) object is activated (when not allready activated) when the client calls
a method. A pooled JITA object behaves like a JITA.
The same goes for the deactivation, a pooled non-JITA object is deactivated
when the client releases it's reference, a JITA object (pooled or not)
deactivates when the method returns with the Done bit is set to
true(automatically or manually). A pooled JITA, deactivates also when the
client releases it's reference.

Willy.

In JITA scenario's Activate is being called when activated in a context
> An example I have shows that Activate() is called not only when pooling is
> enabled and the object is taken from the pool, but EVEN in the abscence of
[quoted text clipped - 83 lines]
>> >>
>> >> Willy.
"Peter Huang" [MSFT] - 16 Jul 2005 08:23 GMT
Hi

I reviewed the thread and find that there is a related issue in the
newsgroup below. And I will reply to you in that queue, you may monitor it.
Subject: Watching the COM+ pool
Newsgroups: microsoft.public.dotnet.framework

Best regards,

Peter Huang
Microsoft Online Partner Support

Signature

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.