How shared functions work

5 pts.
Tags:
.NET Framework
ASP.NET
Development
Memory management
Shared functions
Web development
Hi, Very recently I had a passion for Shared methods. I have read many articles regarding usage of Shared methods and variables and now I am confused whether it is a good choice or not. Let us discuss bu using a simple example. Consider the class below Class User Public Shared Function InsertUser(Byval userId as integer, Byval userName as String) As Boolean 'Some Logic to insert user End Function End Class In my web page (Say "AddUser.aspx") I creating a user as below Dim boolInserted as Boolean = User.InsertUser(1, "Anish George") I have the following questions 1) In the above case What happens when 2 threads simultaneously access the "InsertUser" function? Next questions are regarding memory allocation 2) Consider 2 users are accessing the "AddUser.aspx" page from 2 different computers, simultaneously. In the server memory will there be two representations of the function "InsertUser" (One memory allocation which belongs to User1 and other which belong to User2) 3) What is an application domain? Consider that the function "InsertUser" was not shared and in the "AddUser.aspx" page I am calling the "InsertUser" function as below Dim obj as new User Dim boolInserted as Boolean = obj r.InsertUser(1, "Anish George") In this case ,in the server memory will there be two representations of the function "InsertUser"? Is this the case where Application domain come into picture? Kindly save me from my confusions by helping me find an answer to the above questions Regards, Anish George
ASKED: May 15, 2008  5:34 AM
UPDATED: May 31, 2008  10:18 PM

Answer Wiki

Thanks. We'll let you know when a new response is added.

1. Both users run the function at the same time.

2. No, the function will only be loaded into memory once.

3. I’m not sure. I don’t think there will be two instances loaded into memory.

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following