🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.csharpbuilder.language.csharp
Article #578

Re: Object locking using ReaderWriterLock

#578
From: Marc Rohloff TeamB
Date: Thu, 12 Aug 2004 12:33
25 lines
1736 bytes
On Thu, 12 Aug 2004 10:27:59 +0530, Sunil.P.Thomas wrote:

The first thing is this code has at least 3 syntax errors and doesn't
compile. Please post compilable code as it makes it a lot easier for
us. Also your code has no namespace directive, it is highly
recommended that you add one.

> I want to know , is there any pitfalls in the above class  ?
No. It looks fine to me.

> How we can avoid them ?
I would have done the following which works without a lock and then
used a simple critical section instead of a ReaderWriterLock 
(a CS is a lot more efficient than a RWLock)

 public static bool CanContinue(int usn , string  sessionId  )
 {
    string sess = _loggedUsers[usn];
    return (sess != nil) && (sess==sessionId);
 }


-- 
Marc Rohloff [TeamB]
marc rohloff at myrealbox dot com
Technical Details
Message-ID: <1ggdzdtzuzi58$.dlg@marcrohloff.40tude.net>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <411af77e$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 1efe35,c5e969dc4a2fb0d
X-Google-Attributes: gid1efe35,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Marc Rohloff [TeamB]" <"on request">
Subject: Re: Object locking using ReaderWriterLock
Newsgroups: borland.public.csharpbuilder.language.csharp
User-Agent: 40tude_Dialog/2.0.12.1
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
References: <411af77e$1@newsgroups.borland.com>
Date: Thu, 12 Aug 2004 08:33:29 -0400
Message-ID: <1ggdzdtzuzi58$.dlg@marcrohloff.40tude.net>
NNTP-Posting-Host: 4.131.35.78
X-Trace: newsgroups.borland.com 1092313981 4.131.35.78 (12 Aug 2004 05:33:01 -0700)
Lines: 25
X-Authenticated-User: mrohloff
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail