From 264700bf97de2e4430494cb41201950162fba020 Mon Sep 17 00:00:00 2001 From: James Willcox Date: Wed, 14 Sep 2005 02:32:27 +0000 Subject: lose the dep on avahi-glib, and run the avahi loop in a thread git-svn-id: file:///home/lennart/svn/public/avahi/trunk@580 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe --- avahi-sharp/ServiceTypeBrowser.cs | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'avahi-sharp/ServiceTypeBrowser.cs') diff --git a/avahi-sharp/ServiceTypeBrowser.cs b/avahi-sharp/ServiceTypeBrowser.cs index e436da9..ab6a866 100644 --- a/avahi-sharp/ServiceTypeBrowser.cs +++ b/avahi-sharp/ServiceTypeBrowser.cs @@ -117,20 +117,27 @@ namespace Avahi private void Start () { - if (handle != IntPtr.Zero || (addListeners.Count == 0 && removeListeners.Count == 0)) + if (client.Handle == IntPtr.Zero || handle != IntPtr.Zero || + (addListeners.Count == 0 && removeListeners.Count == 0)) return; - IntPtr domainPtr = Utility.StringToPtr (domain); - handle = avahi_service_type_browser_new (client.Handle, iface, (int) proto, domainPtr, - cb, IntPtr.Zero); - Utility.Free (domainPtr); + lock (client) { + IntPtr domainPtr = Utility.StringToPtr (domain); + handle = avahi_service_type_browser_new (client.Handle, iface, (int) proto, domainPtr, + cb, IntPtr.Zero); + Utility.Free (domainPtr); + } } private void Stop (bool force) { - if (handle != IntPtr.Zero && (force || (addListeners.Count == 0 && removeListeners.Count == 0))) { - avahi_service_type_browser_free (handle); - handle = IntPtr.Zero; + if (client.Handle != IntPtr.Zero && handle != IntPtr.Zero && + (force || (addListeners.Count == 0 && removeListeners.Count == 0))) { + + lock (client) { + avahi_service_type_browser_free (handle); + handle = IntPtr.Zero; + } } } -- cgit