Skip to content

Commit

Permalink
Ensure LocalNode to be stoped before shutting down the NeoSystem
Browse files Browse the repository at this point in the history
  • Loading branch information
erikzhang committed Feb 20, 2019
1 parent d9fc9e9 commit 2bff318
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion neo/NeoSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Neo.Wallets;
using System;
using System.Net;
using System.Threading;

namespace Neo
{
Expand Down Expand Up @@ -40,10 +41,18 @@ public NeoSystem(Store store)
public void Dispose()
{
RpcServer?.Dispose();
ActorSystem.Stop(LocalNode);
EnsureStoped(LocalNode);
ActorSystem.Dispose();
}

public void EnsureStoped(IActorRef actor)
{
Inbox inbox = Inbox.Create(ActorSystem);
inbox.Watch(actor);
ActorSystem.Stop(actor);
inbox.Receive(Timeout.InfiniteTimeSpan);
}

internal void ResumeNodeStartup()
{
suspend = false;
Expand Down

0 comments on commit 2bff318

Please sign in to comment.