I was hoping to synchronise the method but I guess the only way to accomplish this is to 'lock a block'
You really have a good handle on .NET Threading issues
Now back to our regularly scheduled programme..

Thanks Gregory!

Martin-

----- Original Message ----- From: "Gregory Seidman" <[EMAIL PROTECTED]>
To: "Martin Gainty" <[EMAIL PROTECTED]>
Sent: Saturday, July 02, 2005 12:15 PM
Subject: Re: Struts vs .NET???


On Sat, Jul 02, 2005 at 10:31:02AM -0400, Martin Gainty wrote:
} Could you elucidate for me how .NET handles thread synchronisation?
} I ran into a situation where someone wanted a .NET App coded up in 3 days } which worked ok except I ran into a problem where multiple threads were/are
} accessing the same method..my work around was to install a hack which
} turned on a Session variable and a pre-validator function would ensure that
} session variable was indeed turned off before executing the method. Does
} .NET have any support for synchronized method access?
} Feel free to contact me offline...as this WAY WAY WAY O/T

C# has shortcut syntax for locking:

class Foo {
 void Bar() {
   lock(this) {
     //do stuff
   }
 }
}

This is actually shorthand for:

class Foo {
 void Bar() {
   System.Threading.Monitor.Enter(this);
   try {
   } finally [
     System.Threading.Monitor.Exit(this);
   }
 }
}

.NET doesn't have synchronized methods like Java, but it has synchronized
blocks (as above) just like Java. For more information, look into the
System.Threading.Monitor class, which provides an implementation of the
standard monitor synchronization primitive. (Google for Hoare monitor
for more on that.)

} Many Thanks,
} Martin-
--Greg
P.S. I took it off-list since it really is offtopic, but I wouldn't mind
    if you mentioned to the list that I'd provided the information you
    needed.



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to