Skip to content

Instantly share code, notes, and snippets.

@felixlindemann
Last active August 29, 2015 14:16
Show Gist options
  • Save felixlindemann/ea04e8e6595dfb8be582 to your computer and use it in GitHub Desktop.
Save felixlindemann/ea04e8e6595dfb8be582 to your computer and use it in GitHub Desktop.
Dispose of R.Net
public void Dispose()
{
if (this.rEngine != null)
{
try
{
// if any plots are open, they have to be closed
// before shooting down R
int I = this.getInt("length(dev.list())");
for (int i = 0; i < I; i++)
{
this.EvaluateLine("dev.off()");
}
// Shoot down
this.rEngine.Dispose();
this.rEngine = null;
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString(), "Error while shooting down R");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment