Hi, I think your problem is more likely to be an architectural problem than a re-entrance problem.
You are using the cache as a 'definitive' answer whether an user is online or not. But you must understand that the cache can drop its entries for several reasons, for example, due to expiration or under-usage. Thus the cache should only be used as a 'shortcut'. If you cannot find your answer in the cache, you need to go find it somewhere else... Your MarkEntityAsOnline seems to use the cache as its store. You should consider to store the 'onlineness' information somewhere else too, for example in a application static container, in a database, in a (xml) file. There are several solutions for this, but do not rely on the cache alone. HTH // Ryan On 3/27/06, Arvinder Chopra <[EMAIL PROTECTED]> wrote: > In my web application, I have developed a 'Users Online' module (implemented > as a user control) using Atlas. This user control calls a web service (to > let it know that this user is online) as soon and as long as the user has > my web application open in his browser. This same user control has code to > check if a user is online. I can throw this user control in places such as a > data grid which shows lists of users. As soon as a user comes online, a > 'User online' lighbulb lights up next to that user's name in the datagrid > row. The problem is that the User Online icon lights up and goes off > erratically. > > At the heart of this operation is my web service which has 2 methods which I > have copied below. The problem I am running into is that I think I have > reentrancy problems in my web service methods. There is a large number of > web service calls being made to this web service. How can I avoid multiple > threads from entering my web service method simultaneously? > > > <WebMethod()> _ > > Public Sub MarkEntityAsOnline(ByVal EntityClass As String, ByVal EntityId As > String) > > Try > > Dim ctx As HttpContext = HttpContext.Current > > If ctx IsNot Nothing Then > > ctx.Cache.Insert(EntityClass & EntityId, "Y", Nothing, > DateTime.Now.AddMinutes(1), Cache.NoSlidingExpiration) > > End If > > Catch ex As System.Exception > > Finally > > End Try > > End Sub > > <WebMethod()> _ > > Public Function IsEntityOnline(ByVal EntityClass As String, ByVal EntityId > As String) As String > > Dim retVal As Boolean = False > > Try > > Dim ctx As HttpContext = HttpContext.Current > > If ctx IsNot Nothing Then > > Dim cache_item As Object = ctx.Cache.Item(EntityClass & EntityId) > > If cache_item IsNot Nothing Then > > retVal = True > > End If > > End If > > Catch ex As System.Exception > > Finally > > End Try > > Return retVal.ToString().ToUpper() > > End Function > > > =================================== > This list is hosted by DevelopMentor(r) http://www.develop.com > > View archives and manage your subscription(s) at http://discuss.develop.com > =================================== This list is hosted by DevelopMentorĀ® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com
