Re: Synchronization in .Net Remoting

From: Chun Fan (ChunFan_at_discussions.microsoft.com)
Date: 08/29/04


Date: Sun, 29 Aug 2004 11:23:03 -0700

got it. thanks:)

"Sam Santiago" wrote:

> I don't know what's going on, but I don't believe the Monitor object will
> help you create a distributed application object lock. Monitor will allow 1
> thread to lock an object, preventing other threads from accessing it. But
> you are not in control of the threads that access your remote object - it's
> all handled by the remoting infrastructure. In fact, there is no guarantee
> that the same thread services all requests for the same client. You would
> have to write a application level locking mechanism that would "lock" your
> remote object and keep track of which client owns that lock. You would have
> to synchronize within your methods that acquire and release your application
> lock, so Monitor could help there. Good luck.
>
> Thanks,
>
> Sam
>
> --
> _______________________________
> Sam Santiago
> ssantiago@n0spam-SoftiTechture.com
> http://www.SoftiTechture.com
> _______________________________
> "Chun Fan" <ChunFan@discussions.microsoft.com> wrote in message
> news:1DCDF9F3-1C58-4D0C-99CE-512E3B6C4CD6@microsoft.com...
> >
> > /// remote object code
> > [Serializable]
> > public class Data_2:MarshalByRefObject
> > {
> > public Data_2()
> > {
> > m_nID = 2;
> > m_nOwnerActorID = 1;
> > m_strName = "Data 2";
> > dataValueString = "";
> > dataType = "";
> > obj = new object();
> > mutex = new System.Threading.Mutex(true);
> > }
> >
> > public bool TryLock()
> > {
> > // return mutex.WaitOne(100, true);
> >
> > return System.Threading.Monitor.TryEnter(this);
> > }
> >
> > public void Lock()
> > {
> > // mutex.WaitOne();
> > System.Threading.Monitor.Enter(this);
> > }
> >
> > public void Release()
> > {
> > // mutex.ReleaseMutex();
> >
> > System.Threading.Monitor.Pulse(this);
> > System.Threading.Monitor.Exit(this);
> > }
> >
> > public object obj;
> > public System.Threading.Mutex mutex;
> > }
> >
> > /// server code
> > public class RemoteLoader: MarshalByRefObject
> > {
> > public RemoteLoader()
> > {
> > m_arrDatas = new ArrayList();
> > m_arrAssemblies = new ArrayList();
> > }
> >
> >
> > public void LoadAvailableDatas()
> > {
> >
> > string[] DataFiles =
> > Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory, "*.dll");
> >
> > foreach (string filename in DataFiles)
> > {
> > Assembly a = Assembly.LoadFrom(filename);
> > m_arrAssemblies.Add(a);
> > }
> > RemotingConfiguration.Configure( @"..\..\server.exe.config" );
> > }
> >
> >
> >
> > public int Length
> > {
> > get {return m_arrDatas.Count;}
> > }
> >
> > private ArrayList m_arrAssemblies;
> >
> > private ArrayList m_arrDatas;
> > }
> >
> >
> > /// server configuration file
> > <configuration>
> > <system.runtime.remoting>
> > <application name="Server">
> > <service>
> > <wellknown mode="Singleton" type="ConcreteData.Data_2, ConcreteACDATE"
> > objectUri="Data_2_URI" />
> > <channels>
> > <channel ref="http" port="8080" />
> > <channel ref="tcp" port="8081" />
> > </channels>
> > </application>
> > </system.runtime.remoting>
> > </configuration>
> >
> >
> > /// client code
> > /// have been shown in previous posts:)
> >
> > /// client configuration
> > <configuration>
> > <system.runtime.remoting>
> > <application name="Client">
> > <client>
> > <wellknown type="ConcreteACDATE.Data_2, ConcreteACDATE"
> > url="tcp://localhost:8081/Data_2_URI" />
> > </client>
> > <channels>
> >
> > <channel ref="tcp" port="0">
> > <clientProviders>
> > <formatter ref="binary" />
> > </clientProviders>
> > <serverProviders>
> > <formatter ref="binary" typeFilterLevel="Full" />
> > </serverProviders>
> > </channel>
> >
> > </channels>
> > </application>
> > </system.runtime.remoting>
> > </configuration>
> >
> > Is that detailed enough? Thanks a lot!
> >
> > Chun
> >
> > "Sam Santiago" wrote:
> >
> > > Without posting detailed code snippets showing how you configure
> remoting
> > > and your server and client objects it's difficult to say. I think the
> main
> > > point is that there are many other complicating issues to think about
> that
> > > Enterprise Services addresses.
> > >
> > > Thanks,
> > >
> > > Sam
> > >
> > > --
> > > _______________________________
> > > Sam Santiago
> > > ssantiago@n0spam-SoftiTechture.com
> > > http://www.SoftiTechture.com
> > > _______________________________
>
>
>



Relevant Pages

  • Re: Any multithreading CF libraries?
    ... > /// Fuller Monitor implementation than CF.NET supplies. ... > /// its lock count is incremented. ... > public void Enter ... > lock (stateLock) ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: Understanding java.lang.Object.wait()
    ... the lock occurs AFTER the code is out of synchronized block. ... public void run{ ... If several threads that held the same monitor are awoken at the same ... But since they are all in a synchronized block, only one can run - the one who ...
    (comp.lang.java.programmer)
  • Re: Multi-threading article finally "finished" - reviewers welcome
    ... It also violates the naming convention MS spells out in the MSDN ... > Public Sub StartTheThread() ... > releasing a monitor several millions times per second. ... Using a lock: ...
    (microsoft.public.dotnet.framework.clr)
  • Re: Multi-threading article finally "finished" - reviewers welcome
    ... It also violates the naming convention MS spells out in the MSDN ... > Public Sub StartTheThread() ... > releasing a monitor several millions times per second. ... Using a lock: ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Multi-threading article finally "finished" - reviewers welcome
    ... It also violates the naming convention MS spells out in the MSDN ... > Public Sub StartTheThread() ... > releasing a monitor several millions times per second. ... Using a lock: ...
    (microsoft.public.dotnet.general)

Quantcast