Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 2005 > C# 2005
|
C# 2005 For discussion of Visual C# 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 4th, 2008, 08:53 AM
Registered User
 
Join Date: Jan 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Cuncurrent web method WS

Help me...

I'm work in IT organization, and have an interesting task: create e web service for integrate two several systems.

In short-word, my problem is that web service must use an object with global scope. All requests from first system, will be satisfied from a web method that will use an object shared for read and write operation.

I'Have synchronized the access to this object how follow:

1) i create in global.asax a static istance of this object in web service application start function, and a generical static object for synchcronize the first object.

2) in web method called from request, whenever have requested access to the global object, i use the Monitor instrument for synchronize the access to this object, how in this example:

function myWebMethod(){



in this point i must use a global object

Monitor.Enter(Static global object)

try{

reset static global object

use static global object

}

finally

{

Monitor.Exit(Static global object)

}

}

I create a multithreading client and execute fifty parallel thread that does the request. In this test, i' dont find a synchronization problem, BUT i'm not sure! I see that in the critical area the thread behavior is sequenzial.

The necessity of create only global object is, the critical time for instanziate the object, 5 secondi.

My problems are the follow:

1)Is correct syncronized a web method with monitor, or i must use a mutex, in short monitor grant me the synch?

2)In the case above, to kill the sequenzial behaviour of threads, i must implement a pool of object, with the same global logic?

4)IIS create an appdomain for all request or not?this is importante why the use of monitor or mutex

Sorry for english, i wait answers thank you Vito!

- for first answer, i just know the Monitor behavior. I'want know if Monior are used in following context, please listen.

Principal entity of context, web service sir¨¬te:

- web service ws

- static global object in cache MATRIX

- static global object in cache called SYNCH

- monior or (this my enigma) Mutex

Scenary

Clients performe a soap action request, calling a specific web method. Calling WM.

WM behaviour: WM with monitor object lock the SYNCH object, and execute some operation on global object MATRIX.

And at the End relase SYNCH. like this, the suspended request can start.

This WM don't start other thread, i suppose that web service starts a thread for every request.





IMPORTANT: Difference with mutex and monitor:

At the operating-system level, there

are three kernel objects¡ªMutex, Semaphore, and Event

For example, using a Mutex to synchronize your threads instead of a Monitor is about 33 times slower (as pointed out by Jeffrey Richter in his book CLR via C#, mentioned earlier in this chapter). Even

though these kernel objects come with additional overhead, they allow you to perform synchronization tasks that are impossible with the Monitor and ReaderWriterLock classes:

¡ö A Mutex allows synchronization (like a lock) across AppDomain and process

boundaries.



My question:

It's really that web service start a thread for every request? In this case, this threads are in only AppDomain or boundary process? I synchronized with monitor or i must use a Mutex, becouse the mutex is kernel object, across the process?



sorry for english bey , i waiting Vito...








Similar Threads
Thread Thread Starter Forum Replies Last Post
How to INVOKE any WS on server by WS on client ? Abhinavnaresh ASP.NET 2.0 Professional 1 April 4th, 2008 01:09 PM
How to check the parameters passed to web method? karveajit ASP.NET 1.0 and 1.1 Professional 3 December 20th, 2006 05:55 PM
Return Collection object from a Web Method raybo .NET Web Services 2 June 17th, 2006 07:42 AM
Incomplete Result from Web Method pearsonbe .NET Web Services 0 January 28th, 2005 10:34 AM
About method of class in Web Service hueduongit .NET Web Services 5 December 11th, 2003 09:09 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.