Quote:
quote:
Your consumers are all running in different app domains, but they are all connecting to a single program that is hosting the remote class. While each remoting call from the consumer may be in different thread, those threads are still within the context of the same app domain. This is the point of the lock or WaitHandle mechanism: to allow different threads in the same app domain to interact and influence each other.
|
Exactly my thoughts, every invocation of a method in a remote object generates a new thread. This thread is dedicated to a process in another Appdomain, but still it is a local thread for the remote object (or service) so "local" locking mechanisms can be used.
Quote:
quote:
From a standpoint of testing this behavior, could you introduce some manual overrides to the remote class behavior such that you could forcibly delay processing to simulate the simultaneous consumer calls? For example, put a "Console.ReadLine()" call in the process. Your console app that hosts the remote object would wait at this line until keyboard entry. That way you can fire up the multiple test clients to simulate processing delay to show that the thread blocking is working. Once you hit a key in the test host the threads should finish and the consumer will be released.
|
It doesn't have to be a console application that hosts the remote object. That is only convenient for debugging purposes.
Normally I would use IIS hosting or a windows service.
For simulating processing I use "Thread.Sleep()" combined with "Console.WriteLine()" for trace-information.
I've done some testing in the meantime and it works very well when one or more "WaitHandles" are owned by a remote object (not necessarily the same as the engine) that are accessible to all client-processes as properties or through methods. What I've found out so far is that you can define specialized remote "schedule"-objects that implement synchronizing mechanisms that work cross-domain and even over a LAN, simply by publishing waithandles like AutoResetEvent and ManualResetEvent (Monitor is a static class and therefore less easy to use).
The fun of it is that it can be used over IPC TCP and HTTP.
Quote:
quote:I think that remoting is phenomenal! The hard part (personally) is finding applications for it.
|
Remember me mentioning "lazy-evaluation". This technique and other related techniques require statefull (even perpetual-state) objects. Remoting is i.m.o. the easiest way to implement this kind of objects. Especially applications that incorporate extensive logic rather than data-access (e.g. mathematical models) are best implmented as remote-objects, aside from specific security issues. You can allways define web-services as a gateway to the (preferably state-less) web-world.