Created
June 5, 2020 15:24
-
-
Save 2garryn/6d11bf573781edb559f57683a0200808 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class NonBlockingReplicator: INonBlockingReplicator | |
{ | |
public event EventHandler Replicated; | |
private readonly IHttpReplicator _httpReplicator; | |
public NonBlockingReplicator(IHttpReplicator httpReplicator) => _httpReplicator = httpReplicator; | |
public void Replicate(Guid id, string serialized, bool notify = true) => | |
Task.Run(() => _httpReplicator.Replicate(serialized)) | |
.ContinueWith((replicated) => | |
{ | |
if (notify) | |
{ | |
Replicated?.Invoke(this, new ReplicatedOneEvent { Id = id } ); | |
} | |
}); | |
public void Replicate(Dictionary<Guid, string> serialized, bool notify = true) => | |
Task.Run(() => _httpReplicator.Replicate(serialized)) | |
.ContinueWith((replicated) => | |
{ | |
if (notify) | |
{ | |
Replicated?.Invoke(this, new ReplicatedManyEvent { Ids = replicated.Result }); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment