Skip to content

Commit

Permalink
added some threading to allow Service startup w/o waiting on SetupAnd…
Browse files Browse the repository at this point in the history
…Run() to return.
  • Loading branch information
cdhunt committed Sep 10, 2014
1 parent 2ad5209 commit 4ae69bd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion newrelic_perfmon_plugin/Agent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace newrelic_perfmon_plugin
class PerfmonAgent : Agent
{
public override string Guid { get { return "com.automatedops.perfmom_plugin"; } }
public override string Version { get { return "0.1.4"; } }
public override string Version { get { return "0.2.0"; } }

private string Name { get; set; }
private List<Object> Counters { get; set; }
Expand Down
13 changes: 11 additions & 2 deletions newrelic_perfmon_plugin/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using NewRelic.Platform.Sdk;
using Topshelf;
using Topshelf.Runtime;
using System.Threading;

namespace newrelic_perfmon_plugin
{
Expand Down Expand Up @@ -30,6 +31,7 @@ static void Main(string[] args)
class PluginService
{
Runner _runner;
public Thread thread { get; set; }

public PluginService()
{
Expand All @@ -40,9 +42,12 @@ public PluginService()
public void Start()
{
Console.WriteLine("Starting service.");

thread = new Thread(new ThreadStart(_runner.SetupAndRun));
try
{
_runner.SetupAndRun();
thread.Start();
//_runner.SetupAndRun();
}
catch (Exception e)
{
Expand All @@ -55,7 +60,11 @@ public void Stop()
Console.WriteLine("Stopping service in 5 seconds.");
System.Threading.Thread.Sleep(5000);

_runner = null;
if (thread.IsAlive)
{
_runner = null;
thread.Abort();
}
}
}
}

0 comments on commit 4ae69bd

Please sign in to comment.