summaryrefslogtreecommitdiffstats
path: root/avahi-sharp/ServiceTypeBrowser.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/ServiceTypeBrowser.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/ServiceTypeBrowser.cs')
-rw-r--r--avahi-sharp/ServiceTypeBrowser.cs23
1 files changed, 15 insertions, 8 deletions
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;
+ }
}
}