Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I have an asp.net module that does stuff kind of like this:

 

 


Module Stuff

   Dim strHold As String = String.Empty

   Public Sub subDoStuff(ByVal strString As String)
       'Added SyncLock do to paranoia
       SyncLock GetType(Stuff)
           'Clears strHold
           strHold = String.Empty
           'Calls subProcess that does some stuff with strHold
           subProcess()
           'Does some more stuff with strHold
           strHold &= strString
           'Writes strHold somewhere
       End SyncLock
   End Sub

   Private Sub subProcess()
       'Adds some stuff to strHold
       strHold = "This and that"
   End Sub

End Module

 

 

I saw some samples that used SyncLock, got paranoid, and added it to all of my modules that use any type of globals. (I know global variables are the root of all evil, and will cause nations to collapse, but they sure are handy some times.)

 

Question 1: Do I need to use SyncLock?

Question 2: If so, should I use "SyncLock GetType(strHold)" instead?

Posted

May be an better question would be:

 

In ASP.NET, is each client session its own "application" on the server, or is each client session multi-threading from the same code on the server?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...