Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / October 2003

Tip: Looking for answers? Try searching our database.

Thread-safe Code

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Erik J Sawyer - 02 Oct 2003 18:30 GMT
I am considering using web services as an alternative to
DCOM/COM+ components for middle-tier logic.  I have
developed COM+ components in the past, using VB6, but
they were obviously STA, so threading was a minimal
concern.

My question is, how concerned should I be with making my
code thread-safe when using a VB or C# web service?  Will
ASP.Net automatically serialize calls so that each
instance will ignore the others?  I am not maintaining
any component state between calls, and the web service
component itself is fairly simple and single-threaded.

Thanks,
Erik J. Sawyer
Webmaster
Kingsport City Schools
www.K12K.com
Dave - 03 Oct 2003 10:27 GMT
Thread safety is a concern when a resource is shared among multiple threads
and these threads try to access the same resource at the same time. If you
don't do this then you are probably thread safe. If you do have a shared
resource it may still not be a problem is all the accesses are read-only.
The problem usually occurs when one or more threads are trying to modify the
resource simultaneously, or when one is modifying it while other threads are
reading it. It may not always be obvious when you are accessing a shared
resource - that is part of your job as a developer.

One simple approach to making your code thread-safe is to take a lock on a
private object whenever you access the shared resource.

> I am considering using web services as an alternative to
> DCOM/COM+ components for middle-tier logic.  I have
[quoted text clipped - 14 lines]
> Kingsport City Schools
> www.K12K.com
Erik J Sawyer - 03 Oct 2003 18:06 GMT
The only shared resource I plan to access currently is
SQL Server; I will ensure that any multi-table updates
are encapsulated in a transaction, and I use stored procs
to return @@Identity for any ID columns.

- Erik J Sawyer

>-----Original Message-----
>Thread safety is a concern when a resource is shared among multiple threads
[quoted text clipped - 27 lines]
>> Kingsport City Schools
>> www.K12K.com

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.