473,796 Members | 2,460 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.P age
{
//Variables
IVisitProtocol m_oVisitProtoco l
public void Configure(IVisi teProtocol oVisiteProtocol )
{
this.m_oVisitPr otocol = oVisitProtocol;
if (!this.GeneralC ontrol(out Message))
this.m_oVisitPr otocol.DisplayM essage(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(EventArg s 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, IVisiteProtocol e
{
//variables
//Public and Private Methods
override protected void OnInit(EventArg s e)
{
base.configure( this);
InitializeCompo nent();
base.OnInit(e);
}
//creating other classes instances
//like Product oProduct = new Product(); etc..

}

Thanks.
Jan 13 '06 #1
4 1624
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.P age
{
//Variables
IVisitProtocol m_oVisitProtoco l
public void Configure(IVisi teProtocol oVisiteProtocol )
{
this.m_oVisitPr otocol = oVisitProtocol;
if (!this.GeneralC ontrol(out Message))
this.m_oVisitPr otocol.DisplayM essage(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(EventArg s 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, IVisiteProtocol e
{
//variables
//Public and Private Methods
override protected void OnInit(EventArg s e)
{
base.configure( this);
InitializeCompo nent();
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.P age 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.P age
{
//Variables
IVisitProtocol m_oVisitProtoco l
public void Configure(IVisi teProtocol oVisiteProtocol )
{
this.m_oVisitPr otocol = oVisitProtocol;
if (!this.GeneralC ontrol(out Message))
this.m_oVisitPr otocol.DisplayM essage(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(EventArg s 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, IVisiteProtocol e
{
//variables
//Public and Private Methods
override protected void OnInit(EventArg s e)
{
base.configure( this);
InitializeCompo nent();
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.P age 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.P age
{
//Variables
IVisitProtocol m_oVisitProtoco l
public void Configure(IVisi teProtocol oVisiteProtocol )
{
this.m_oVisitPr otocol = oVisitProtocol;
if (!this.GeneralC ontrol(out Message))
this.m_oVisitPr otocol.DisplayM essage(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(EventArg s 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, IVisiteProtocol e
{
//variables
//Public and Private Methods
override protected void OnInit(EventArg s e)
{
base.configure( this);
InitializeCompo nent();
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.P age 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.P age
> {
> //Variables
> IVisitProtocol m_oVisitProtoco l
> public void Configure(IVisi teProtocol oVisiteProtocol )
> {
> this.m_oVisitPr otocol = oVisitProtocol;
> if (!this.GeneralC ontrol(out Message))
> this.m_oVisitPr otocol.DisplayM essage(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(EventArg s 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, IVisiteProtocol e
> {
> //variables
> //Public and Private Methods
> override protected void OnInit(EventArg s e)
> {
> base.configure( this);
> InitializeCompo nent();
> 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
6658
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 potential problems for thread-safety. So far, I'm only confused. I need a proper explanation for the concept so I can understand how to write thread-safe functions in the future. My apologies for posting a long routine.
9
2100
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 for web servers. These apps' re tested with a stress test. That doesn' t work for my module. I searched the web but didn' t find a solution that satisfies me. I think that thread safety errors don' t occur reproduceable and so they' re hard to test and...
4
2793
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 operations?
22
37756
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() However, this throws and error: System.Threading.ThreadStateException: Thread is running or terminated; it can not restart.
4
2577
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 as a single application. I was wondering if there is a "Thread-Safety Analysis Wizard"? I'm sure I'm grossly off-base with the following, so I'm prepared to be embarrassed. Please point me in the right direction!
6
3142
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 to the client. Before adding data to the arraylist, I check if the depth of the arraylist is longer than iMaxQueueDepth, and if it is, I clear the arraylist. Is it possible that while I am clearing the arraylist, the ThreadMain at the same time...
1
3637
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 thread safety issue. Are consts thread safe? Would the following example create any thread safety issues? Would you recommend using static readonly members instead of constants?
13
3612
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
4155
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 with xdebug.so. So far as I can tell, the options I used to configure php did not ask for thread-safety, and I also don't see any options to *dis*able thread-safety. Configure --help does show several threading-related options, but none for
13
11480
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
9529
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10457
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10231
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10176
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,...
0
9054
agi2029
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...
0
6792
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5443
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4119
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
2
3733
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.