Skip to content

Commit

Permalink
Fix for #151
Browse files Browse the repository at this point in the history
  • Loading branch information
Scott Offen committed Nov 18, 2016
1 parent e99e98a commit 893bae2
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/Grapevine/Server/RestServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -261,14 +261,6 @@ public IRestServer LogToConsole()
return this;
}

/// <summary>
/// For use in routes that want to stop the server; starts a new thread and then calls Stop on the server
/// </summary>
public void ThreadSafeStop()
{
new Thread(Stop).Start();
}

private void HandleRequests()
{
while (Listener.IsListening)
Expand Down Expand Up @@ -483,4 +475,16 @@ public void Stop()
_listener.Stop();
}
}


public static class RestServerExtensions
{
/// <summary>
/// For use in routes that want to stop the server; starts a new thread and then calls Stop on the server
/// </summary>
public static void ThreadSafeStop(this IRestServer server)
{
new Thread(server.Stop).Start();
}
}
}

0 comments on commit 893bae2

Please sign in to comment.