DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Fri, 17 Aug 2007 11:08:15 -0400,    posted on: microsoft.public.dotnet.framework.aspnet        back       

Thread Index
  1    Max2006 am
          2    bruce barker
          3    John Saunders [MVP] john.saunders at trizetto.com
          4    Max2006 am
          5    John Saunders [MVP] john.saunders at trizetto.com
          6    (Steven Cheng[MSFT])
          7    (Steven Cheng[MSFT])


Can we use static table adapters in highly concurrent web sites?   
Hi,

I am trying to make our business logic layer components more efficient. We 
use strongly typed datasets and TableAdapters.

Is it a good idea to use a static TableAdpater to share the static instance 
among all sessions?

My business logic components are like this:


[DataObject]
public static class AccountBLL
{
private static ProfileTableAdapter m_ProfileTableAdapter = null;
private static ProfileTableAdapter AccountProfileTableAdapter
{
    get
    {
 if (m_ProfileTableAdapter == null)
     m_ProfileTableAdapter = new ProfileTableAdapter();

 return m_ProfileTableAdapter;
    }
}

[DataObjectMethodAttribute(DataObjectMethodType.Select, true)]
public static AppDataSet.ProfileDataTable GetAllProfiles()
{
    AppDataSet.ProfileDataTable dt;
    dt = AccountProfileTableAdapter.GetData();
    return dt;
}
}


Whole sessions within the web application are going to share a single 
instance of ProfileTableAdapter because it is static. I am a bit concern in 
high concurrent situations. Is it safe?

Any help would be appreciated,
Max
Date:Fri, 17 Aug 2007 11:08:15 -0400   Author:  

Re: Can we use static table adapters in highly concurrent web sites?   
its a bad idea. you will need to add locking to your current code so 
that only one call can run at a time or it will fail when concurrent 
requests happen (connection is use errors).

you can still use static methods, but each method should create and 
release its own tableadapter.

-- bruce (sqlwork.com)

Max2006 wrote:

> Hi,
> 
> I am trying to make our business logic layer components more efficient. We 
> use strongly typed datasets and TableAdapters.
> 
> Is it a good idea to use a static TableAdpater to share the static instance 
> among all sessions?
> 
> My business logic components are like this:
> 
> 
> [DataObject]
> public static class AccountBLL
> {
> private static ProfileTableAdapter m_ProfileTableAdapter = null;
> private static ProfileTableAdapter AccountProfileTableAdapter
> {
>     get
>     {
>  if (m_ProfileTableAdapter == null)
>      m_ProfileTableAdapter = new ProfileTableAdapter();
> 
>  return m_ProfileTableAdapter;
>     }
> }
> 
> [DataObjectMethodAttribute(DataObjectMethodType.Select, true)]
> public static AppDataSet.ProfileDataTable GetAllProfiles()
> {
>     AppDataSet.ProfileDataTable dt;
>     dt = AccountProfileTableAdapter.GetData();
>     return dt;
> }
> }
> 
> 
> Whole sessions within the web application are going to share a single 
> instance of ProfileTableAdapter because it is static. I am a bit concern in 
> high concurrent situations. Is it safe?
> 
> Any help would be appreciated,
> Max
> 
> 
> 
> 
> 
> 
Date:Fri, 17 Aug 2007 09:09:40 -0700   Author:  

Re: Can we use static table adapters in highly concurrent web sites?   
"Max2006" <alanalan1@newsgroup.nospam> wrote in message 
news:uXGksBO4HHA.5160@TK2MSFTNGP05.phx.gbl...

> Hi,
>
> I am trying to make our business logic layer components more efficient. We 
> use strongly typed datasets and TableAdapters.


Have you done some profiling that suggests that your TableAdapters are a 
significant source of poor performance?

If not, then don't touch them! Never optimize where you _think_ the 
performance problem is. Don't solve the wrong problem.

Especially don't touch them by making them static, which means that multiple 
requests will be using the same data at the same time.
-- 
John Saunders [MVP]
Date:Fri, 17 Aug 2007 13:22:58 -0400   Author:  

Re: Can we use static table adapters in highly concurrent web sites?   
Does this means that TableAdapter is not thread safe?


"Max2006" <alanalan1@newsgroup.nospam> wrote in message 
news:uXGksBO4HHA.5160@TK2MSFTNGP05.phx.gbl...

> Hi,
>
> I am trying to make our business logic layer components more efficient. We 
> use strongly typed datasets and TableAdapters.
>
> Is it a good idea to use a static TableAdpater to share the static 
> instance among all sessions?
>
> My business logic components are like this:
>
>
> [DataObject]
> public static class AccountBLL
> {
> private static ProfileTableAdapter m_ProfileTableAdapter = null;
> private static ProfileTableAdapter AccountProfileTableAdapter
> {
>    get
>    {
> if (m_ProfileTableAdapter == null)
>     m_ProfileTableAdapter = new ProfileTableAdapter();
>
> return m_ProfileTableAdapter;
>    }
> }
>
> [DataObjectMethodAttribute(DataObjectMethodType.Select, true)]
> public static AppDataSet.ProfileDataTable GetAllProfiles()
> {
>    AppDataSet.ProfileDataTable dt;
>    dt = AccountProfileTableAdapter.GetData();
>    return dt;
> }
> }
>
>
> Whole sessions within the web application are going to share a single 
> instance of ProfileTableAdapter because it is static. I am a bit concern 
> in high concurrent situations. Is it safe?
>
> Any help would be appreciated,
> Max
>
>
>
>
>
> 
Date:Fri, 17 Aug 2007 13:51:45 -0400   Author:  

Re: Can we use static table adapters in highly concurrent web sites?   
"Max2006" <alanalan1@newsgroup.nospam> wrote in message 
news:eXf4CdP4HHA.4436@TK2MSFTNGP03.phx.gbl...

>
> Does this means that TableAdapter is not thread safe?


Of course it's not. Almost nothing _is_ thread safe! You should assume that 
any class is ***not*** thread safe unless it tells you otherwise!
-- 
John Saunders [MVP]
Date:Fri, 17 Aug 2007 18:04:51 -0400   Author:  

Re: Can we use static table adapters in highly concurrent web sites?   
Hi Max,

Yes, as for TableAdapter classes, they're complex classes that may contain 
internal fields/members that help perform the data accessing code logic, 
this will make the class(its methods) become context sensitive and not 
thread-safe. I agree that you should void use shared TableAdapter if 
possible.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.
Date:Mon, 20 Aug 2007 01:58:42 GMT   Author:  

Re: Can we use static table adapters in highly concurrent web sites?   
Hi Max,

Do you have any further question on this? If so, please don't hesitate to 
post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
 	

This posting is provided "AS IS" with no warranties, and confers no rights.
Date:Wed, 22 Aug 2007 09:51:25 GMT   Author:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us