Kittyfisto / SharpRemote

A .NET remoting library
MIT License
12 stars 5 forks source link

OutOfProcessSilo should have a Stop() method #59

Closed Kittyfisto closed 6 years ago

Kittyfisto commented 6 years ago

Currently, the Silo can only be started once, from which point onward a child process will be started (and restarted, if necessary), but it doesn't have a dedicated Stop(). Instead a user has to Dispose() of the existing silo and then create a new silo.

This is extremely cumbersome to use in client code. Instead, the following should be possible:

var silo = new OutOfProcessSilo(...);
silo.Start();

var proxy = silo.CreateProxy<IFoo>(....);
proxy.Do();

silo.Stop();
...
// No child process is running
...
silo.Start();
proxy.Do();

In between silo.Stop() and silo.Start(), no child process should be running.
Proxy objects returned by CreateProxy should remain valid after the 2nd call to Start().

TBD: Should CreateGrain make use of this feature as well? Currently, grains can only be created after Start() has been called and therefore are not re-created once Stop(), Start() has been called.

Kittyfisto commented 6 years ago

OutOfProcessSilo.Stop() now exists, but some tests will still need to be added. Furthermore, SocketEndPoint still logs an error once Stop() is called because the host process is simply killed (and the connection is reset because of it). This will of-course have to be changed so that no error is logged in case of a desired shutdown. Maybe it's as simple as calling Disconnect(), will have to see in the next few days...