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 / April 2006

Tip: Looking for answers? Try searching our database.

Forcing single in-line web service execution?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
eross@cots.com - 28 Apr 2006 16:12 GMT
Noob here,

I am trying to manage calls from multiple clients to my web service by
only letting one execute at a time and forcing the others to wait.

Code is as follows:

------------------------------
<WebMethod()> Public Function myFunction(ByVal sXMLData As String) As
String

Static Dim objLock As New Object

SyncLock objLock

              (do some stuff here)

               Return sRtn

End Synclock
End Function
--------------------------------

I'm sure there's something I'm missing here, as multiple clients coming
in simultaneously will execute things at the same time.  Am I missing
the point of Synclock?

Can someone point me in the right direction?

TIA
Shaun McDonnell - 28 Apr 2006 18:10 GMT
What you need to do is create a Singleton object and then lock that object.
That way even though users's might be calling the webservice at the same
time, the object would only allow itself to be called by one thread at a
time.

Google the "Singleton Pattern."

Shaun McDonnell

> Noob here,
>
[quoted text clipped - 24 lines]
>
> TIA
Greg Young - 29 Apr 2006 20:28 GMT
This will only work within the same worker process ..

If the webservice instances are all runnig in the same process you could
even just lock on the type to have synchronized behavior between multiple
instances.

Generally though webservices are run in a multiple process configuration
(i.e. multiple worker processes). In this case neither of the above
solutions will work as both are scoped to the process level.

If you are running multiple worker processes on the same machine you can use
a mutex
http://msdn2.microsoft.com/en-us/library/system.threading.mutex(VS.80).aspx
to synchronize all (including between processes)

If you are running multiple processes on multiple machines, you would need
to put up a manager process to manage the synchronization between them.

Cheers,

Greg
> What you need to do is create a Singleton object and then lock that
> object. That way even though users's might be calling the webservice at
[quoted text clipped - 33 lines]
>>
>> TIA
Shaun McDonnell - 29 Apr 2006 22:09 GMT
You are correct.  A mutex would be the answer if you're web service spans
multiple w3wp.exe's.

Shaun McDonnell

> This will only work within the same worker process ..
>
[quoted text clipped - 56 lines]
>>>
>>> TIA

Rate this thread:







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



©2008 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.