Just a quick question. If i had a static var, then all users coming onto my
site will be sharing the same var. So if i have a class that is a singleton
would the same happen there?
Basically i have a class that will only ever have one instance so, singleton
makes sense. But due to asp and lots of connecting users it had me wondering
if the singleton would work as one isntance per user or one instance for all
users (not what i want)
ThanksFirst, I'll assume you're speaking of asp.net and not just asp.
They are different things.
Here is an example of a asp.net singleton:
10/24/2005
Web Session Wrapper for storing and retrieving objects
http://sholliday.spaces.live.com/blog/
PS
You should mark
public class WebSessionDataStore
as [Serializable]
and make any objects you put in there serializable if you go to sql server
session state management.
"PokerMan" <nospam@.pokercat.co.ukwrote in message
news:ukskBEjaHHA.4788@.TK2MSFTNGP04.phx.gbl...
Quote:
Originally Posted by
Hey guys
>
Just a quick question. If i had a static var, then all users coming onto
my
Quote:
Originally Posted by
site will be sharing the same var. So if i have a class that is a
singleton
Quote:
Originally Posted by
would the same happen there?
>
Basically i have a class that will only ever have one instance so,
singleton
Quote:
Originally Posted by
makes sense. But due to asp and lots of connecting users it had me
wondering
Quote:
Originally Posted by
if the singleton would work as one isntance per user or one instance for
all
Quote:
Originally Posted by
users (not what i want)
>
Thanks
>
>
yes .net sorry.
I am more wanting to know how it will handle a singleton implementation not
how to implement one, tho i cant see an singleton implementation on that
blog? Is it very different to a standard one on .net?
"sloan" <sloan@.ipass.netwrote in message
news:%23GxTXJjaHHA.1216@.TK2MSFTNGP03.phx.gbl...
Quote:
Originally Posted by
First, I'll assume you're speaking of asp.net and not just asp.
>
They are different things.
>
Here is an example of a asp.net singleton:
>
10/24/2005
Web Session Wrapper for storing and retrieving objects
http://sholliday.spaces.live.com/blog/
>
>
PS
You should mark
public class WebSessionDataStore
>
as [Serializable]
>
and make any objects you put in there serializable if you go to sql server
session state management.
>
>
>
"PokerMan" <nospam@.pokercat.co.ukwrote in message
news:ukskBEjaHHA.4788@.TK2MSFTNGP04.phx.gbl...
Quote:
Originally Posted by
>Hey guys
>>
>Just a quick question. If i had a static var, then all users coming onto
my
Quote:
Originally Posted by
>site will be sharing the same var. So if i have a class that is a
singleton
Quote:
Originally Posted by
>would the same happen there?
>>
>Basically i have a class that will only ever have one instance so,
singleton
Quote:
Originally Posted by
>makes sense. But due to asp and lots of connecting users it had me
wondering
Quote:
Originally Posted by
>if the singleton would work as one isntance per user or one instance for
all
Quote:
Originally Posted by
>users (not what i want)
>>
>Thanks
>>
>>
>
>
If you have static values it is one instance for *all* users. If you want
one instance for *each* user then you could store your object in the
Session.
"PokerMan" <nospam@.pokercat.co.ukwrote in message
news:ukskBEjaHHA.4788@.TK2MSFTNGP04.phx.gbl...
Quote:
Originally Posted by
Hey guys
>
Just a quick question. If i had a static var, then all users coming onto
my site will be sharing the same var. So if i have a class that is a
singleton would the same happen there?
>
Basically i have a class that will only ever have one instance so,
singleton makes sense. But due to asp and lots of connecting users it had
me wondering if the singleton would work as one isntance per user or one
instance for all users (not what i want)
>
Thanks
>
Ah found ur singletom implementation on the blog, my apologies. And its
similar to mine, not sure why you use a method and dont set the instance as
a property get{} but its the same in essence.
So in answer to my original question a singleton will work as i expect?
Single instance per user, not one instance effected by all users?
"sloan" <sloan@.ipass.netwrote in message
news:%23GxTXJjaHHA.1216@.TK2MSFTNGP03.phx.gbl...
Quote:
Originally Posted by
First, I'll assume you're speaking of asp.net and not just asp.
>
They are different things.
>
Here is an example of a asp.net singleton:
>
10/24/2005
Web Session Wrapper for storing and retrieving objects
http://sholliday.spaces.live.com/blog/
>
>
PS
You should mark
public class WebSessionDataStore
>
as [Serializable]
>
and make any objects you put in there serializable if you go to sql server
session state management.
>
>
>
"PokerMan" <nospam@.pokercat.co.ukwrote in message
news:ukskBEjaHHA.4788@.TK2MSFTNGP04.phx.gbl...
Quote:
Originally Posted by
>Hey guys
>>
>Just a quick question. If i had a static var, then all users coming onto
my
Quote:
Originally Posted by
>site will be sharing the same var. So if i have a class that is a
singleton
Quote:
Originally Posted by
>would the same happen there?
>>
>Basically i have a class that will only ever have one instance so,
singleton
Quote:
Originally Posted by
>makes sense. But due to asp and lots of connecting users it had me
wondering
Quote:
Originally Posted by
>if the singleton would work as one isntance per user or one instance for
all
Quote:
Originally Posted by
>users (not what i want)
>>
>Thanks
>>
>>
>
>
Did you look at entry at the correct date?
private WebSessionDataStore() //constructor
{
this.m_itemCollection = new HybridDictionary();
}
/// <summary>
/// Singleton representing WebSessionDataStore.
/// </summary>
/// <returns></returns>
public static WebSessionDataStore GetInstance()
{
//other stuff here
}
Singleton is a DESIGN PATTERN, not "just an asp.net thing".
http://www.dofactory.com/Patterns/PatternSingleton.aspx
static/shared variables are another thing.
Based on your description of what you want
if the singleton would work as one isntance per user or one instance for
Quote:
Originally Posted by
Quote:
Originally Posted by
allusers (not what i want)
I've shown you how to create a true SINGLETON for the web environment.
You can find more by googling also:
http://www.google.com/search?hl=en&...n+%22asp.net%22
"PokerMan" <nospam@.pokercat.co.ukwrote in message
news:e23xaSjaHHA.4716@.TK2MSFTNGP02.phx.gbl...
Quote:
Originally Posted by
yes .net sorry.
>
I am more wanting to know how it will handle a singleton implementation
not
Quote:
Originally Posted by
how to implement one, tho i cant see an singleton implementation on that
blog? Is it very different to a standard one on .net?
>
>
>
"sloan" <sloan@.ipass.netwrote in message
news:%23GxTXJjaHHA.1216@.TK2MSFTNGP03.phx.gbl...
Quote:
Originally Posted by
First, I'll assume you're speaking of asp.net and not just asp.
They are different things.
Here is an example of a asp.net singleton:
10/24/2005
Web Session Wrapper for storing and retrieving objects
http://sholliday.spaces.live.com/blog/
PS
You should mark
public class WebSessionDataStore
as [Serializable]
and make any objects you put in there serializable if you go to sql
server
Quote:
Originally Posted by
Quote:
Originally Posted by
session state management.
"PokerMan" <nospam@.pokercat.co.ukwrote in message
news:ukskBEjaHHA.4788@.TK2MSFTNGP04.phx.gbl...
Quote:
Originally Posted by
Hey guys
>
Just a quick question. If i had a static var, then all users coming
onto
Quote:
Originally Posted by
Quote:
Originally Posted by
my
Quote:
Originally Posted by
site will be sharing the same var. So if i have a class that is a
singleton
Quote:
Originally Posted by
would the same happen there?
>
Basically i have a class that will only ever have one instance so,
singleton
Quote:
Originally Posted by
makes sense. But due to asp and lots of connecting users it had me
wondering
Quote:
Originally Posted by
if the singleton would work as one isntance per user or one instance
for
Quote:
Originally Posted by
Quote:
Originally Posted by
all
Quote:
Originally Posted by
users (not what i want)
>
Thanks
>
>
>
>
My singleton example piggybacks off of SESSION, therefore you will get "one
per user".
I use a method ... because I think thats what GOF (gang of four) does.
http://www.dofactory.com/Patterns/PatternSingleton.aspx
uses a method also.
....
Again, because I piggy back off of Session, its "one per user".
If I were to piggyback off of Application (object, instead of Session)
(which I actually do in another scenario)...
it would be "all users".
"PokerMan" <nospam@.pokercat.co.ukwrote in message
news:eSVmAZjaHHA.2172@.TK2MSFTNGP04.phx.gbl...
Quote:
Originally Posted by
Ah found ur singletom implementation on the blog, my apologies. And its
similar to mine, not sure why you use a method and dont set the instance
as
Quote:
Originally Posted by
a property get{} but its the same in essence.
>
So in answer to my original question a singleton will work as i expect?
Single instance per user, not one instance effected by all users?
>
>
>
"sloan" <sloan@.ipass.netwrote in message
news:%23GxTXJjaHHA.1216@.TK2MSFTNGP03.phx.gbl...
Quote:
Originally Posted by
First, I'll assume you're speaking of asp.net and not just asp.
They are different things.
Here is an example of a asp.net singleton:
10/24/2005
Web Session Wrapper for storing and retrieving objects
http://sholliday.spaces.live.com/blog/
PS
You should mark
public class WebSessionDataStore
as [Serializable]
and make any objects you put in there serializable if you go to sql
server
Quote:
Originally Posted by
Quote:
Originally Posted by
session state management.
"PokerMan" <nospam@.pokercat.co.ukwrote in message
news:ukskBEjaHHA.4788@.TK2MSFTNGP04.phx.gbl...
Quote:
Originally Posted by
Hey guys
>
Just a quick question. If i had a static var, then all users coming
onto
Quote:
Originally Posted by
Quote:
Originally Posted by
my
Quote:
Originally Posted by
site will be sharing the same var. So if i have a class that is a
singleton
Quote:
Originally Posted by
would the same happen there?
>
Basically i have a class that will only ever have one instance so,
singleton
Quote:
Originally Posted by
makes sense. But due to asp and lots of connecting users it had me
wondering
Quote:
Originally Posted by
if the singleton would work as one isntance per user or one instance
for
Quote:
Originally Posted by
Quote:
Originally Posted by
all
Quote:
Originally Posted by
users (not what i want)
>
Thanks
>
>
>
>
it can be coded either way, depends on how you code it.
-- bruce (sqlwork.com)
PokerMan wrote:
Quote:
Originally Posted by
Ah found ur singletom implementation on the blog, my apologies. And its
similar to mine, not sure why you use a method and dont set the instance as
a property get{} but its the same in essence.
>
So in answer to my original question a singleton will work as i expect?
Single instance per user, not one instance effected by all users?
>
>
>
"sloan" <sloan@.ipass.netwrote in message
news:%23GxTXJjaHHA.1216@.TK2MSFTNGP03.phx.gbl...
Quote:
Originally Posted by
>First, I'll assume you're speaking of asp.net and not just asp.
>>
>They are different things.
>>
>Here is an example of a asp.net singleton:
>>
>10/24/2005
>Web Session Wrapper for storing and retrieving objects
>http://sholliday.spaces.live.com/blog/
>>
>>
>PS
>You should mark
>public class WebSessionDataStore
>>
>as [Serializable]
>>
>and make any objects you put in there serializable if you go to sql server
>session state management.
>>
>>
>>
>"PokerMan" <nospam@.pokercat.co.ukwrote in message
>news:ukskBEjaHHA.4788@.TK2MSFTNGP04.phx.gbl...
Quote:
Originally Posted by
>>Hey guys
>>>
>>Just a quick question. If i had a static var, then all users coming onto
>my
Quote:
Originally Posted by
>>site will be sharing the same var. So if i have a class that is a
>singleton
Quote:
Originally Posted by
>>would the same happen there?
>>>
>>Basically i have a class that will only ever have one instance so,
>singleton
Quote:
Originally Posted by
>>makes sense. But due to asp and lots of connecting users it had me
>wondering
Quote:
Originally Posted by
>>if the singleton would work as one isntance per user or one instance for
>all
Quote:
Originally Posted by
>>users (not what i want)
>>>
>>Thanks
>>>
>>>
>>
>
>
0 comments:
Post a Comment