473,326 Members | 2,147 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

ASP.net and thread safety

hello, can anyone please tell me if the following structure is thread safe

visit.cs
class Visit : System.Web.UI.Page
{
//Variables
IVisitProtocol m_oVisitProtocol
public void Configure(IVisiteProtocol oVisiteProtocol)
{
this.m_oVisitProtocol = oVisitProtocol;
if (!this.GeneralControl(out Message))
this.m_oVisitProtocol.DisplayMessage(Message);
}
private bool GeneralControl(out string Message)
{
//checks that need to be done on evry request
Message = checks_value/string.empty;
return true/false;
}
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
//more code dealing with the site skeleton
}
//more Public and Private Methodes
}
product.aspx.cs
//this the code behind of product.aspx and almost evry page has the same
structure
public class product : Visit, IVisiteProtocole
{
//variables
//Public and Private Methods
override protected void OnInit(EventArgs e)
{
base.configure(this);
InitializeComponent();
base.OnInit(e);
}
//creating other classes instances
//like Product oProduct = new Product(); etc..

}

Thanks.
Jan 13 '06 #1
4 1603
Simo,
I question the validity / logic of deriving class Visit from the Page Class.
There is no reason why each Page instance can't make a method call on a
separate class, or even use a Server Control that does this type of thing.

Each page instance and every object instance that it runs is "thread safe"
to the extent that the fields / members aren't static, because each runs on
an individual and separate thread.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Simo" wrote:
hello, can anyone please tell me if the following structure is thread safe

visit.cs
class Visit : System.Web.UI.Page
{
//Variables
IVisitProtocol m_oVisitProtocol
public void Configure(IVisiteProtocol oVisiteProtocol)
{
this.m_oVisitProtocol = oVisitProtocol;
if (!this.GeneralControl(out Message))
this.m_oVisitProtocol.DisplayMessage(Message);
}
private bool GeneralControl(out string Message)
{
//checks that need to be done on evry request
Message = checks_value/string.empty;
return true/false;
}
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
//more code dealing with the site skeleton
}
//more Public and Private Methodes
}
product.aspx.cs
//this the code behind of product.aspx and almost evry page has the same
structure
public class product : Visit, IVisiteProtocole
{
//variables
//Public and Private Methods
override protected void OnInit(EventArgs e)
{
base.configure(this);
InitializeComponent();
base.OnInit(e);
}
//creating other classes instances
//like Product oProduct = new Product(); etc..

}

Thanks.

Jan 13 '06 #2
SEB
thank you Peter for taking time to respond.
I am going to start with your second part. I belive it confirm that evry
code is thread safe as long as there is no static fields / members
even it's not "a good logic" or there is a btter way to do it.
Is that rtight Peter?

about the first part. I did post an other question here but (with all my
respect to evry one) no one gave an answer.
here is my question again Peter and hope you will give an answer or any
redirection of who to do what i am looking for

let's says we have over 100 apsx pages
on each page there have to be checks (no matter if they are simple or
complexe)
exmple of these checks is to validate the Remote IP and check if HTTPS is ON
what is the best way, creating/using a control (no matter server / user /
custome) then each time you have to go throught each page to add/remove a
propertise in case your customer came up with a strange ideas or make the
Visite class that derive from System.Web.UI.Page then let Visit make all the
checks and any changes to the initial checks will be only to Visit class then
make every aspx class derive from Visit and every page.
all i nee to do after that is recompile the project and done with it

i must says that i am using Visit class for more things in other projects
because it really worked with me the first time but i will appreciate your
help if you can redirect me to the right way




"Peter Bromberg [C# MVP]" wrote:
Simo,
I question the validity / logic of deriving class Visit from the Page Class.
There is no reason why each Page instance can't make a method call on a
separate class, or even use a Server Control that does this type of thing.

Each page instance and every object instance that it runs is "thread safe"
to the extent that the fields / members aren't static, because each runs on
an individual and separate thread.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Simo" wrote:
hello, can anyone please tell me if the following structure is thread safe

visit.cs
class Visit : System.Web.UI.Page
{
//Variables
IVisitProtocol m_oVisitProtocol
public void Configure(IVisiteProtocol oVisiteProtocol)
{
this.m_oVisitProtocol = oVisitProtocol;
if (!this.GeneralControl(out Message))
this.m_oVisitProtocol.DisplayMessage(Message);
}
private bool GeneralControl(out string Message)
{
//checks that need to be done on evry request
Message = checks_value/string.empty;
return true/false;
}
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
//more code dealing with the site skeleton
}
//more Public and Private Methodes
}
product.aspx.cs
//this the code behind of product.aspx and almost evry page has the same
structure
public class product : Visit, IVisiteProtocole
{
//variables
//Public and Private Methods
override protected void OnInit(EventArgs e)
{
base.configure(this);
InitializeComponent();
base.OnInit(e);
}
//creating other classes instances
//like Product oProduct = new Product(); etc..

}

Thanks.

Jan 13 '06 #3
SEB,
For something like this, I would consider creating an HttpModule and
plugging this into your web.config. Then your checks could be done
automatically by interceptiing the appropriate methods in the ASPX page
lifecycle.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"SEB" wrote:
thank you Peter for taking time to respond.
I am going to start with your second part. I belive it confirm that evry
code is thread safe as long as there is no static fields / members
even it's not "a good logic" or there is a btter way to do it.
Is that rtight Peter?

about the first part. I did post an other question here but (with all my
respect to evry one) no one gave an answer.
here is my question again Peter and hope you will give an answer or any
redirection of who to do what i am looking for

let's says we have over 100 apsx pages
on each page there have to be checks (no matter if they are simple or
complexe)
exmple of these checks is to validate the Remote IP and check if HTTPS is ON
what is the best way, creating/using a control (no matter server / user /
custome) then each time you have to go throught each page to add/remove a
propertise in case your customer came up with a strange ideas or make the
Visite class that derive from System.Web.UI.Page then let Visit make all the
checks and any changes to the initial checks will be only to Visit class then
make every aspx class derive from Visit and every page.
all i nee to do after that is recompile the project and done with it

i must says that i am using Visit class for more things in other projects
because it really worked with me the first time but i will appreciate your
help if you can redirect me to the right way




"Peter Bromberg [C# MVP]" wrote:
Simo,
I question the validity / logic of deriving class Visit from the Page Class.
There is no reason why each Page instance can't make a method call on a
separate class, or even use a Server Control that does this type of thing.

Each page instance and every object instance that it runs is "thread safe"
to the extent that the fields / members aren't static, because each runs on
an individual and separate thread.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Simo" wrote:
hello, can anyone please tell me if the following structure is thread safe

visit.cs
class Visit : System.Web.UI.Page
{
//Variables
IVisitProtocol m_oVisitProtocol
public void Configure(IVisiteProtocol oVisiteProtocol)
{
this.m_oVisitProtocol = oVisitProtocol;
if (!this.GeneralControl(out Message))
this.m_oVisitProtocol.DisplayMessage(Message);
}
private bool GeneralControl(out string Message)
{
//checks that need to be done on evry request
Message = checks_value/string.empty;
return true/false;
}
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
//more code dealing with the site skeleton
}
//more Public and Private Methodes
}
product.aspx.cs
//this the code behind of product.aspx and almost evry page has the same
structure
public class product : Visit, IVisiteProtocole
{
//variables
//Public and Private Methods
override protected void OnInit(EventArgs e)
{
base.configure(this);
InitializeComponent();
base.OnInit(e);
}
//creating other classes instances
//like Product oProduct = new Product(); etc..

}

Thanks.

Jan 13 '06 #4
SEB
Peter,
This sounds more intersting
would please submit any simple (if you have it of corse) of how to intercept
the appropriate methods in the ASPX page form HttpModule?

Thanks much Peter.

"Peter Bromberg [C# MVP]" wrote:
SEB,
For something like this, I would consider creating an HttpModule and
plugging this into your web.config. Then your checks could be done
automatically by interceptiing the appropriate methods in the ASPX page
lifecycle.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"SEB" wrote:
thank you Peter for taking time to respond.
I am going to start with your second part. I belive it confirm that evry
code is thread safe as long as there is no static fields / members
even it's not "a good logic" or there is a btter way to do it.
Is that rtight Peter?

about the first part. I did post an other question here but (with all my
respect to evry one) no one gave an answer.
here is my question again Peter and hope you will give an answer or any
redirection of who to do what i am looking for

let's says we have over 100 apsx pages
on each page there have to be checks (no matter if they are simple or
complexe)
exmple of these checks is to validate the Remote IP and check if HTTPS is ON
what is the best way, creating/using a control (no matter server / user /
custome) then each time you have to go throught each page to add/remove a
propertise in case your customer came up with a strange ideas or make the
Visite class that derive from System.Web.UI.Page then let Visit make all the
checks and any changes to the initial checks will be only to Visit class then
make every aspx class derive from Visit and every page.
all i nee to do after that is recompile the project and done with it

i must says that i am using Visit class for more things in other projects
because it really worked with me the first time but i will appreciate your
help if you can redirect me to the right way




"Peter Bromberg [C# MVP]" wrote:
Simo,
I question the validity / logic of deriving class Visit from the Page Class.
There is no reason why each Page instance can't make a method call on a
separate class, or even use a Server Control that does this type of thing.

Each page instance and every object instance that it runs is "thread safe"
to the extent that the fields / members aren't static, because each runs on
an individual and separate thread.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Simo" wrote:

> hello, can anyone please tell me if the following structure is thread safe
>
> visit.cs
> class Visit : System.Web.UI.Page
> {
> //Variables
> IVisitProtocol m_oVisitProtocol
> public void Configure(IVisiteProtocol oVisiteProtocol)
> {
> this.m_oVisitProtocol = oVisitProtocol;
> if (!this.GeneralControl(out Message))
> this.m_oVisitProtocol.DisplayMessage(Message);
> }
> private bool GeneralControl(out string Message)
> {
> //checks that need to be done on evry request
> Message = checks_value/string.empty;
> return true/false;
> }
> protected override void OnInit(EventArgs e)
> {
> base.OnInit(e);
> //more code dealing with the site skeleton
> }
> //more Public and Private Methodes
> }
>
>
> product.aspx.cs
> //this the code behind of product.aspx and almost evry page has the same
> structure
> public class product : Visit, IVisiteProtocole
> {
> //variables
> //Public and Private Methods
> override protected void OnInit(EventArgs e)
> {
> base.configure(this);
> InitializeComponent();
> base.OnInit(e);
> }
> //creating other classes instances
> //like Product oProduct = new Product(); etc..
>
> }
>
> Thanks.

Jan 13 '06 #5

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

Similar topics

4
by: Jonathan Burd | last post by:
Greetings everyone, Here is a random string generator I wrote for an application and I'm wondering about the thread-safety of this function. I was told using static and global variables cause...
9
by: Alexander Fleck | last post by:
Hi, I' ve to make a software module thread safe. I know how to realize that and what' re the main topics of thread safety. But I don' t know how thread safety can be tested. I read about a test...
4
by: The Crow | last post by:
for example i have static readonly SqlParameter and i want to clone them at runtime. as clone operation will not write to SqlParameter object, just reading, should i lock that object during read...
22
by: Brett | last post by:
I have a second thread, t2, that errors out and will stop. It's status is then "Stopped". I try to start t2 from thread 1, t1, by checking If t2.threadstate = "Stopped" Then t2.start() ...
4
by: Warren Sirota | last post by:
Hi, I've got a method that I want to execute in a multithreaded environment (it's a specialized spider. I want to run a whole bunch of copies at low priority as a service). It works well running...
6
by: fniles | last post by:
I am using VB.NET 2003 and a socket control to receive and sending data to clients. As I receive data in 1 thread, I put it into an arraylist, and then I remove the data from arraylist and send it...
1
by: paul.hester | last post by:
Hi all, All of the classes in my DAL are static, with constants defining the stored procedures and parameters. I've been having some problems with my site which makes me wonder if there's a...
13
by: arun.darra | last post by:
Are the following thread safe: 1. Assuming Object is any simple object Object* fn() { Object *p = new Object(); return p; } 2. is return by value thread safe?
0
by: Graham Wideman | last post by:
Folks: Can anyone tell me what controls php's "thread safety" feature? I have an installation where phpinfo() is showing Thread safety: enabled, whereas I need it disabled in order to work...
13
by: Henri.Chinasque | last post by:
Hi all, I am wondering about thread safety and member variables. If I have such a class: class foo { private float m_floater = 0.0; public void bar(){ m_floater = true; }
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.