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/DomainBrowser.cs | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'avahi-sharp/DomainBrowser.cs') diff --git a/avahi-sharp/DomainBrowser.cs b/avahi-sharp/DomainBrowser.cs index cc93641..76438f8 100644 --- a/avahi-sharp/DomainBrowser.cs +++ b/avahi-sharp/DomainBrowser.cs @@ -122,20 +122,26 @@ 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_domain_browser_new (client.Handle, iface, (int) proto, domainPtr, (int) btype, - cb, IntPtr.Zero); - Utility.Free (domainPtr); + lock (client) { + IntPtr domainPtr = Utility.StringToPtr (domain); + handle = avahi_domain_browser_new (client.Handle, iface, (int) proto, domainPtr, (int) btype, + cb, IntPtr.Zero); + Utility.Free (domainPtr); + } } private void Stop (bool force) { - if (handle != IntPtr.Zero && (force || (addListeners.Count == 0 && removeListeners.Count == 0))) { - avahi_domain_browser_free (handle); - handle = IntPtr.Zero; + if (client.Handle != IntPtr.Zero && handle != IntPtr.Zero && + (force || (addListeners.Count == 0 && removeListeners.Count == 0))) { + lock (client) { + avahi_domain_browser_free (handle); + handle = IntPtr.Zero; + } } } -- cgit