Skip to content

Commit

Permalink
Made AbstractLicenseValidator implement IDisposable
Browse files Browse the repository at this point in the history
Not sure what "fancy-word"-principle this seems to break but essentially
every time you instantiate the AbstractLicenseValidator it would create
a timer thread which would never be removed until the garbage collector
did its job. This is a very strange behavior because it forces us to
call DisableFutureChecks as if it was a dispose method. This opens up
the license validator to be used in bigger server environments.
  • Loading branch information
stemarie committed Jan 9, 2013
1 parent 14f9877 commit ac279b4
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion Rhino.Licensing/AbstractLicenseValidator.cs
Expand Up @@ -15,7 +15,7 @@ namespace Rhino.Licensing
/// <summary>
/// Base license validator.
/// </summary>
public abstract class AbstractLicenseValidator
public abstract class AbstractLicenseValidator : IDisposable
{
/// <summary>
/// License validator logger
Expand All @@ -41,6 +41,7 @@ public abstract class AbstractLicenseValidator
"nist1.sjc.certifiedtime.com"
};

private bool disposed;
private readonly string licenseServerUrl;
private readonly Guid clientId;
private readonly string publicKey;
Expand Down Expand Up @@ -563,5 +564,32 @@ public void DisableFutureChecks()
disableFutureChecks = true;
nextLeaseTimer.Dispose();
}

public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}

~AbstractLicenseValidator()
{
Dispose(false);
}

protected virtual void Dispose(bool disposing)
{
if (disposed)
return;

if (disposing)
{
nextLeaseTimer.Dispose();
}

// release any unmanaged objects
// set the object references to null

disposed = true;
}
}
}

0 comments on commit ac279b4

Please sign in to comment.