summaryrefslogtreecommitdiffstats
path: root/avahi-sharp/ServiceBrowser.cs
diff options
context:
space:
mode:
authorJames Willcox <snopr@snorp.net>2005-09-14 02:32:27 +0000
committerJames Willcox <snopr@snorp.net>2005-09-14 02:32:27 +0000
commit264700bf97de2e4430494cb41201950162fba020 (patch)
treeb7131e3afc84e0459e17860a43208b21b6286362 /avahi-sharp/ServiceBrowser.cs
parent4a10eaeee609b84972ef2b2d0a0fab8a3664891a (diff)
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
Diffstat (limited to 'avahi-sharp/ServiceBrowser.cs')
-rw-r--r--avahi-sharp/ServiceBrowser.cs20
1 files changed, 14 insertions, 6 deletions
diff --git a/avahi-sharp/ServiceBrowser.cs b/avahi-sharp/ServiceBrowser.cs
index a96040c..5da7ea4 100644
--- a/avahi-sharp/ServiceBrowser.cs
+++ b/avahi-sharp/ServiceBrowser.cs
@@ -129,22 +129,30 @@ 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);
IntPtr typePtr = Utility.StringToPtr (type);
- handle = avahi_service_browser_new (client.Handle, iface, (int) proto, typePtr, domainPtr,
- cb, IntPtr.Zero);
+
+ lock (client) {
+ handle = avahi_service_browser_new (client.Handle, iface, (int) proto, typePtr, domainPtr,
+ cb, IntPtr.Zero);
+ }
Utility.Free (domainPtr);
Utility.Free (typePtr);
}
private void Stop (bool force)
{
- if (handle != IntPtr.Zero && (force || (addListeners.Count == 0 && removeListeners.Count == 0))) {
- avahi_service_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_browser_free (handle);
+ handle = IntPtr.Zero;
+ }
}
}