Skip to content

Commit 8d75ea7

Browse files
authored
Merge FixIssue4
Fixed Issue #4
2 parents 1dc9f29 + 687314e commit 8d75ea7

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

src/SingleInstance.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public static class SingleInstance
1717

1818
/// <summary>
1919
/// Intended to be on app startup
20-
/// Initializes service if the call is from first instance
20+
/// Initializes service if the call is from first instance.
2121
/// Signals the first instance if it already exists
2222
/// </summary>
2323
/// <param name="uniqueName">A unique name for IPC channel</param>
@@ -41,7 +41,16 @@ private static void SignalFirstInstance(string channelName, IList<string> comman
4141
{
4242
var bus = new TinyMessageBus(channelName);
4343
var serializedArgs = commandLineArgs.Serialize();
44-
bus.PublishAsync(serializedArgs);
44+
bus.PublishAsync(serializedArgs).Wait();
45+
WaitTillMessageGetsPublished(bus);
46+
}
47+
48+
private static void WaitTillMessageGetsPublished(TinyMessageBus bus)
49+
{
50+
while (bus.MessagesPublished != 1)
51+
{
52+
Thread.Sleep(10);
53+
}
4554
}
4655

4756
private static void CreateRemoteService(ISingleInstance instance, string channelName)

0 commit comments

Comments
 (0)