X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=avahi-sharp%2FClient.cs;h=02763d40d67be6357ef00355a39b22e1d13dcfe1;hb=d6ce91c0b5258c2e107415704413f42edfab2c30;hp=6d39469072947cb6fd0f7ad694be45df239d013d;hpb=c809f13a12f9ac155ae6c49b73a931714b70b4dc;p=catta diff --git a/avahi-sharp/Client.cs b/avahi-sharp/Client.cs index 6d39469..02763d4 100644 --- a/avahi-sharp/Client.cs +++ b/avahi-sharp/Client.cs @@ -286,10 +286,15 @@ namespace Avahi public void Dispose () { if (handle != IntPtr.Zero) { - avahi_client_free (handle); - avahi_simple_poll_quit (spoll); - avahi_simple_poll_free (spoll); - handle = IntPtr.Zero; + lock (this) { + avahi_client_free (handle); + handle = IntPtr.Zero; + + avahi_simple_poll_quit (spoll); + Monitor.Wait (this); + + avahi_simple_poll_free (spoll); + } } } @@ -370,6 +375,7 @@ namespace Avahi try { lock (this) { avahi_simple_poll_loop (spoll); + Monitor.Pulse (this); } } catch (Exception e) { Console.Error.WriteLine ("Error in avahi-sharp event loop: " + e);