diff --git a/PluginCommon/PluginManager.cs b/PluginCommon/PluginManager.cs index 0112c1b..5015584 100644 --- a/PluginCommon/PluginManager.cs +++ b/PluginCommon/PluginManager.cs @@ -39,6 +39,8 @@ namespace PluginCommon { /// private byte[] mFileData; + private DateTime mLastPing; + /// /// Constructor, invoked from CreateInstanceAndUnwrap(). @@ -46,6 +48,8 @@ namespace PluginCommon { public PluginManager() { Debug.WriteLine("PluginManager ctor (id=" + AppDomain.CurrentDomain.Id + ")"); + mLastPing = DateTime.Now; + // Seems to require [SecurityCritical] //Type lsc = Type.GetType("System.Runtime.Remoting.Lifetime.LifetimeServices"); //PropertyInfo prop = lsc.GetProperty("LeaseTime"); @@ -75,7 +79,9 @@ namespace PluginCommon { public int Ping(int val) { Debug.WriteLine("PluginManager Ping tid=" + Thread.CurrentThread.ManagedThreadId + " (id=" + AppDomain.CurrentDomain.Id + "): " + val); - return val + 1; + int result = (int)(DateTime.Now - mLastPing).TotalSeconds; + mLastPing = DateTime.Now; + return result; } /// diff --git a/SourceGen/Sandbox/DomainManager.cs b/SourceGen/Sandbox/DomainManager.cs index a871dc3..813f2d8 100644 --- a/SourceGen/Sandbox/DomainManager.cs +++ b/SourceGen/Sandbox/DomainManager.cs @@ -84,9 +84,10 @@ namespace SourceGen.Sandbox { // waits for the currently-executing timer event to finish. So wrap // everything in try/catch. try { - mPluginManager.Instance.Ping(0); - //Debug.WriteLine("KeepAlive tid=" + - // System.Threading.Thread.CurrentThread.ManagedThreadId); + int result = mPluginManager.Instance.Ping(1000); + Debug.WriteLine("KeepAlive tid=" + + System.Threading.Thread.CurrentThread.ManagedThreadId + + " result=" + result); } catch (Exception ex) { Debug.WriteLine("Keep-alive timer failed: " + ex.Message); }