473,581 Members | 2,338 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

STA object in Session and Thread Affiliation

Here's a question that I've not been able to get a definitive answer to.

Creating an STA object (such as a typical VB6 object) and assigning to the
ASP Session store is a bad thing.

It's a bad thing because it forces IIS to affiliate the Session with the
Thread on which the STA object is created.

This means all subsequent requests for that session can only be handled by
that worker thread and can therefore result it in poor performance as
requests queue up to access the thread they are affiliated with.

My question(s) is/are this:

Is this affilation now set in stone for the life time of the session?

Does removing the STA object from the session remove the affiliation or is
IIS/ASP just not that clever?

Thanks,

Anthony.
Feb 6 '06 #1
12 2199

"Anthony Jones" <An*@yadayadaya da.com> wrote in message
news:e6******** ******@TK2MSFTN GP09.phx.gbl...
Here's a question that I've not been able to get a definitive answer to.

Creating an STA object (such as a typical VB6 object) and assigning to the
ASP Session store is a bad thing.

It's a bad thing because it forces IIS to affiliate the Session with the
Thread on which the STA object is created.

This means all subsequent requests for that session can only be handled by
that worker thread and can therefore result it in poor performance as
requests queue up to access the thread they are affiliated with.

My question(s) is/are this:

Is this affilation now set in stone for the life time of the session?
sure
Does removing the STA object from the session remove the affiliation or is
IIS/ASP just not that clever?
Sure.

ISP Session uses a workaround. But your VB class, needs to be persistable
(this is just a property). And persistance, needs to be implemented, so
within the VB6 class, you need to write the properties to a propertybag.
In the session, they will be written to a byte array and vice versa when
red.
Persistable objects like ADO recordsets as well, do not claim threads or RAM
(with ISP Session only) resources as soon as the session is persisted.
--
compatible web farm Session replacement for Asp and Asp.Net
http://www.nieropwebconsult.nl/asp_session_manager.htm
Thanks,

Anthony.


Feb 7 '06 #2
Thanks for the reply.

I don't use the session object to store state between requests.

What I was wondering is whether a page could place an object in the Session
object then server execute one or more other pages that could maniputlate
this object. Finally the original page would remove the object from Session
before completing it's response to the client.

Between requests Session contains nothing. However I very much suspected
that even this transistory assignment of an object to the Session would
irrevocably nail the Session to the work thread.

:( pity that it would be useful.

Cheers,

Anthony.
Feb 7 '06 #3

"Anthony Jones" <An*@yadayadaya da.com> wrote in message
news:u8******** ******@TK2MSFTN GP15.phx.gbl...
Thanks for the reply.

I don't use the session object to store state between requests.

What I was wondering is whether a page could place an object in the
Session
object then server execute one or more other pages that could maniputlate
this object. Finally the original page would remove the object from
Session
before completing it's response to the client.

Between requests Session contains nothing. However I very much suspected
that even this transistory assignment of an object to the Session would
irrevocably nail the Session to the work thread.


Unless your object is marked as 'Both' and is free-threaded, that would not
happen.

And I suspect that Server.Execute does the following.
It detaches the current session
Attaches it to the target page,
executes that page,
detaches
reattaches the current page.

So basically, your system should not hang even if your object is marked as
'Apartment'.

After server.execute, remove your object

'for instance
Session.Content s.Remove "myobject"
Feb 7 '06 #4
>So basically, your system should not hang even if your object is marked as
'Apartment'.
Yes once a request has been handed over to a worker thread then any server
executes are performed by the same thread. I wasn't concerned that it might
hang.
After server.execute, remove your object 'for instance
Session.Conten ts.Remove "myobject"


Thats the key point. Does the line above remove the Sessions affiliation
with the thread.

Come to think of it when exactly does the affiliation get created?

1) When an STA object is first assigned into the Session object

OR

2) When a ASP processing of a request is finished and an STA object is found
to be in the Session object.

If the 2 then all is well because by then the object is gone (barring
errors, some work in a custom 500.100 page is probably warranted)

However I still suspect it is 1 and once in place stays put.

Anthony.
Feb 7 '06 #5

"Anthony Jones" <An*@yadayadaya da.com> wrote in message
news:Oz******** ******@TK2MSFTN GP09.phx.gbl...
So basically, your system should not hang even if your object is marked
as
'Apartment' .
Yes once a request has been handed over to a worker thread then any server
executes are performed by the same thread. I wasn't concerned that it
might
hang.
After server.execute, remove your object

'for instance
Session.Conte nts.Remove "myobject"


Thats the key point. Does the line above remove the Sessions affiliation
with the thread.


It must be. We are not talking about .NET garbage collection, where the true
destroyment of an instance happens at any time (unless you use non-default
approaches)

If you destroy an object, IIS -will- anticipate on that. The object is
immediately gone including affiliation.

Anyway, imagine that I am wrong (unlikely here), still, the thread must
finish the current page until it would be released for another page request.

Are you having execution times of ASP pages above say, 5 seconds (per
request)?
Come to think of it when exactly does the affiliation get created?
I'm not -the- COM expert at this, but you should understand that 'apartment'
objects, in fact use a hidden window and each hidden window waits and
processes windows messages.
As long as the object is active, the thread is kidnapped for the object and
it won't be released by IIS for another user session.
1) When an STA object is first assigned into the Session object
true.
OR

2) When a ASP processing of a request is finished and an STA object is
found
to be in the Session object.
well, if a thread was assigned to a current asp page, that thread won't be
used for other pages as long as the page did not finish. It has no relation
with apartment affinity.
If you -leave- STA objects in the session, you'll have a problem.
If the 2 then all is well because by then the object is gone (barring
errors, some work in a custom 500.100 page is probably warranted)

However I still suspect it is 1 and once in place stays put.

Anthony.


Feb 8 '06 #6
>>>Session.Cont ents.Remove "myobject"

Thats the key point. Does the line above remove the Sessions affiliation
with the thread.
It must be. We are not talking about .NET garbage collection, where the truedestroyment of an instance happens at any time (unless you use non-default
approaches)


I guess I've just being a bit lazy.

Here is an experiment I've just run.

'VB6 ActiveX dll project "FindThread "
'Class Info
Public Property Get ThreadID() as Long
ThreadID = App.ThreadID
End Property

'Thread.asp
<%
Dim o
Set o = Server.CreateOb ject("FindThrea d.Info")
Response.Write o.ThreadID
%>

'Affiliate.asp
<%
Dim o
Set o = Server.CreateOb ject("MSXML2.DO MDocument.3.0")
Set Session.Content s.Item("test") = o

Session.Content s.Remove "test"
'Also tried:-
'Set Session.Content s.Item("test") = Nothing
'and:-
'Session.Conten ts.RemoveAll

%>

In browser:-

Visit Thread.asp and repeatedly press refresh.
Returned ID jumps about various threads.

Visit Affiliate.asp return to Thread.asp and continue pressing refreash
Returned ID remains the same ID.

From this is appears that a Session once affiliated remains affiliated
despite the fact that the Session no longer holds any references to STA
objects.

Tried it with the FreeThreaded DOM and the session remained unaffiliated.

Pity there isn't a Session.Unaffil iate method.

:(



Feb 8 '06 #7

"Anthony Jones" <An*@yadayadaya da.com> wrote in message
news:uK******** ******@TK2MSFTN GP14.phx.gbl...
Session.Con tents.Remove "myobject"

Thats the key point. Does the line above remove the Sessions
affiliation
with the thread.

It must be. We are not talking about .NET garbage collection, where the

true
destroyment of an instance happens at any time (unless you use non-default
approaches)


I guess I've just being a bit lazy.

Here is an experiment I've just run.

'VB6 ActiveX dll project "FindThread "
'Class Info
Public Property Get ThreadID() as Long
ThreadID = App.ThreadID
End Property

Pity there isn't a Session.Unaffil iate method.


Just curious. Does CreateObject("" ) instead of Server.CreateOb ject make a
difference?

Feb 8 '06 #8
>Just curious. Does CreateObject("" ) instead of Server.CreateOb ject make a
difference?


Nope same effect.

Feb 8 '06 #9

"Anthony Jones" <An*@yadayadaya da.com> wrote in message
news:es******** ******@TK2MSFTN GP15.phx.gbl...
Just curious. Does CreateObject("" ) instead of Server.CreateOb ject make a
difference?


Nope same effect.


This must be because there is an option 'keep in memory' so the VBruntime is
not unloaded unless IIS 6 issues a special com function which unloads
unreferenced com objects.

Feb 9 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2015
by: Alex | last post by:
I'm having a problem porting an ASP solution to ASPX. In the ASP solution I'm accessing a DCOM server, create sub DCOM objects and call functions from VB script on the ASP pages. The DCOM object handles are stored in session variables. This works fine without a problem. Ported it to ASPX, accessing the same DCOM server from code behind...
4
1831
by: Al Cohen | last post by:
We've got a few methods that take a long time to complete. We're in the process of starting to launch these as separate threads, and having the web form refresh every few seconds to report the method's progress. Communication between "new" thread and web page is via the Session object. (Not rocket science so far.) The first problem that...
8
1498
by: MattB | last post by:
Hello I am starting a new thread in a button click event. This thread calls an method which sends emails, I don't want the page to wait for the emails to finish going out as it slows the user down. I have to set a session to null in the same click method but when I do this I get this funny error.
2
2279
by: John Mullin | last post by:
We are having a problem which appears similar to a previous posting: http://groups.google.com/groups?hl=en&lr=&frame=right&th=d97f552e10f8c94c&seekm=OZw33z9EDHA.2312%40TK2MSFTNGP10.phx.gbl#link1 In the current release of our system, we decided to "wrap" the ASP.NET Session and Application objects to improve code clarity and accuracy. For...
2
2086
by: Gavin Lyons via .NET 247 | last post by:
Hello, I'm writing a newsletter application which uses backgroundthreading. I'm using Session variable to report on progresswhile it loops through a dataset. The 'Status.aspx' pagerefreshes every 5 seconds while outputing the Session variables.My problem is, once the page redirects to 'Status.aspx' its showthe that's it only gets half through...
2
2118
by: Markus Prediger | last post by:
Hi NG, I have an asp.net project that uses an vb6 com object for some database-manipulation (I cannot rewrite it in .net, sorry, its not my decision). I want it to be instanciated seperately for each session, so that three users can connect to three different databases. But I get crazy because: -With interop all users share one...
3
1659
by: ESmith | last post by:
I have multi-page form where I pass an object between pages as follows: On each page: // What page to go to next private void btnContinue_Click(object sender, System.EventArgs e) { if (Page.IsValid) { MyXferObj obj = new MyXferObj();
13
1743
by: | last post by:
Simple question, I think... I'm storing an object in the Session object. In the code behind I read that object: trx = CType(Session("Transaction"), BOCSTransaction) If I change any properties, I have to store it back into the session object to "update" it, right? Or will the changes to my object automatically be saved back into the...
5
1997
by: jamie.jamazon | last post by:
I'm currently developing a small MVC framework using classic ASP (don't ask me why!) At it's core it calls the controller script which does the heavy logic and builds disconnected recordsets of the required data then transparently "includes" a page template asp script using a Server.Execute. Because of the limitations of Server.Execute and...
0
7862
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8144
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8301
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7894
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8169
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5670
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5361
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3803
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2300
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.