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 / .NET Framework / New Users / August 2004

Tip: Looking for answers? Try searching our database.

Wierd Synchronization Problem in Using .Net Framework Remoting --

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Chun Fan - 26 Aug 2004 01:55 GMT
I am recently using .net remoting to develop a distributed application and
some synchronization problem bothered for a long time.

The problem looks as following:
There is one server application that hosts a remote object, "mydata". This
remote object is configured as a singlton object. Three functions are
developed within this object to provide synchronized data access:
public class MyData :MarshalByRefObject{

...
public void Lock(){
     System.Threading.Monitor.Enter(this);
}

public void Release(){
     System.Threading.Monitor.Exit(this);
}

public bool TryLock(){
     return System.Threading.Monitor.TryEnter(this);
}
...
}

And two client applications with similar behavior that at first, each client
application tries to obtain the lock on mydata by invoking mydata.Lock();
then does some processing. After the processing is done, the client will
display a message box by invoking 'MessageBox.show()' and waiting for user's
input. After the user's input is received, the client will invoke
mydata.Release() to release the lock on mydata such that other clients may be
able to access mydata.

So I started the first client. The client obtained the lock and displayed
the message box, waiting for my input. Then the second client was started. If
everything were working, the second client should have been blocked since it
can not obtain the lock. Unfortunately, the second client just went on as if
it had got the lock and also displays the message box!

The more wierd thing was that after a random length of time(several minutes
to hours), the lock could work!, i.e. before one client releases the lock,
the other one is blocked at the mydata.Lock() invocation!

So could anybody help me to tell me what's wrong here? Or anybody can tell
me how to implment such a locking in the .net remoting? Thanks a lot!

For one more thing, I am using VS.net 2003 pro and Windows XP running one a
P4 desktop. Thanks!

Signature

Sincerely

Chun

Chun Fan - 26 Aug 2004 02:01 GMT
More information I got:
If I do nothing after starts the client, i.e. not trying to access the
remote object, for several minutes, the blocking mechanism works smoothly.
Anyone can give me a hand to let me know what's wrong here? Is that my
program error or a bug of .net framework? Thanks a lot!

> I am recently using .net remoting to develop a distributed application and
> some synchronization problem bothered for a long time.
[quoted text clipped - 43 lines]
> For one more thing, I am using VS.net 2003 pro and Windows XP running one a
> P4 desktop. Thanks!

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.