BravesCharm Dec 7, 10:57 am show options
Newsgroups: microsoft.publi c.dotnet.distri buted_apps
From: "BravesChar m" <mastrauc...@gm ail.com>
Date: 7 Dec 2004 10:57:40 -0800
Local: Tues, Dec 7 2004 10:57 am
Subject: Have trouble with reference counts!
Reply | Reply to Author | Forward | Print | Individual Message | Show
original | Remove | Report Abuse
I'm developing a website in .NET. Now every user that logs into the
website registers a token with a Token Manger by MSMQ. The Token
Manager is a Windows Service that stores all tokens to keep a count of
how many times a particular token is registered on the system (other
parts of the system that has nothing to do with the website can also
communicate with the Token manager and registers that token with the
Token Manger). When the user logs out, it un-registers that token with
the Token manager, and if the Token Manager Ref count is at zero (No
other part of the system is using the token), it deletes that token.
Now where my problem comes in with Sessions in ASP.NET and State Server
and how .NET does Serialization. When a customer logs in, it registers
the token and stores it into a class that has a dispose pattern as well
as a finalizer. When ASP.NET switches the class between State Server
and IIS it gets Serialized/Desterilized. When it gets Desterilized it
will create a new instance of the class and store it into the Session
variables. Now when the page is done executing, it will call the
finalizer for that class which un-registers the token with the Token
manager which screws everything up! So what I needed was a way to have
some way of keeping a reference count between processes so I know when
to release the token. I thought the best way to do this was by using
Semaphores. The only problem, you cannot query the current count of a
semaphore without calling ReleaseSemaphor e, so i'm not really able to
get the reference count with Semaphores. I found NtQuerySemaphor e but
for some reason it always returns 1 and no the actural count.
So may question is, can anyone tell me the best way to keep the
reference count between processes? 3 3236
BravesCharm,
The object that registers and unregisters the token shouldn't be doing
this. Rather, I would just hook into the Session start and end events
(provided through the global class) and register unregister the token there.
This will allow you to retain your custom information on the object, without
having to worry about registration.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m
"BravesChar m" <ma*********@gm ail.com> wrote in message
news:11******** **************@ z14g2000cwz.goo glegroups.com.. . BravesCharm Dec 7, 10:57 am show options
Newsgroups: microsoft.publi c.dotnet.distri buted_apps From: "BravesChar m" <mastrauc...@gm ail.com> Date: 7 Dec 2004 10:57:40 -0800 Local: Tues, Dec 7 2004 10:57 am Subject: Have trouble with reference counts! Reply | Reply to Author | Forward | Print | Individual Message | Show original | Remove | Report Abuse
I'm developing a website in .NET. Now every user that logs into the website registers a token with a Token Manger by MSMQ. The Token Manager is a Windows Service that stores all tokens to keep a count of how many times a particular token is registered on the system (other parts of the system that has nothing to do with the website can also communicate with the Token manager and registers that token with the Token Manger). When the user logs out, it un-registers that token with the Token manager, and if the Token Manager Ref count is at zero (No other part of the system is using the token), it deletes that token.
Now where my problem comes in with Sessions in ASP.NET and State Server and how .NET does Serialization. When a customer logs in, it registers the token and stores it into a class that has a dispose pattern as well as a finalizer. When ASP.NET switches the class between State Server and IIS it gets Serialized/Desterilized. When it gets Desterilized it will create a new instance of the class and store it into the Session variables. Now when the page is done executing, it will call the finalizer for that class which un-registers the token with the Token manager which screws everything up! So what I needed was a way to have some way of keeping a reference count between processes so I know when to release the token. I thought the best way to do this was by using Semaphores. The only problem, you cannot query the current count of a semaphore without calling ReleaseSemaphor e, so i'm not really able to get the reference count with Semaphores. I found NtQuerySemaphor e but for some reason it always returns 1 and no the actural count.
So may question is, can anyone tell me the best way to keep the reference count between processes?
If you are using Session Server is Session start and end reliable?
Nicholas Paldino,
This will not work because Session_End is only supported in InProc
mode. I will not be able to unregister the token because the event
would never gets called. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Elbert Lev |
last post by:
Please correct me if I'm wrong.
Python (as I understand) uses reference counting to determine when to
delete the object. As soon as the object goes out of the scope it is
deleted. Python does not use garbage collection (as Java does).
So if the script runs a loop:
for i in range(100):
f = Obj(i)
|
by: ash |
last post by:
hi
does anyone has any experience with flyweight pattern with refernce
counting
i want to share objects between multiple clients and want to delete
the object from shared pool when the last client deletes a refernce to
it
|
by: Jason Heyes |
last post by:
To my understanding, std::vector does not use reference counting to avoid
the overhead of copying and initialisation. Where can I get a reference
counted implementation of std::vector? Thanks.
|
by: Kalle Rutanen |
last post by:
Hello
I implemented reference counting in my program, and found out many
problems associated with it. I wonder if the following problems can be
solved automatically rather manually ?
1. In its member function, an object manages to destroy last
reference to itself and thus destructs before the end of the member
function.
|
by: Tony Johansson |
last post by:
Hello Experts!
I reading a book called programming with design pattern revealed
by Tomasz Muldner and here I read something that I don't understand
completely.
It says
"A garbarage collector, such as the one used in Java, maintains a record of
whether or not
an object is currentlys being used. An unused object is tagged as garbage,
| |
by: Tony Johansson |
last post by:
Hello Experts!
I reading a book called programming with design pattern revealed
by Tomasz Muldner and here I read something that I don't understand
completely.
It says
"A garbarage collector, such as the one used in Java, maintains a record of
whether or not
an object is currentlys being used. An unused object is tagged as garbage,
|
by: aaronfude |
last post by:
Hi,
Please consider the following class (it's not really my class, but it's
a good example for my question):
class Vector {
int myN;
double *myX;
Vector(int n) : myN(n), myX(new double) { }
double &operator()(int i) { return myX; }
|
by: oec.deepak |
last post by:
Hi
Cn any one telll me what is Reference counting in C++.
|
by: Astley Le Jasper |
last post by:
Sorry for the numpty question ...
How do you find the reference name of an object?
So if i have this
bob = modulename.objectname()
how do i find that the name is 'bob'
|
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 usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |