]> git.meshlink.io Git - catta/blobdiff - avahi-sharp/Client.cs
remove avahi.pot from SVN again
[catta] / avahi-sharp / Client.cs
index 8ec6616d4403b956201f9d91c38884631540e5e2..02763d40d67be6357ef00355a39b22e1d13dcfe1 100644 (file)
@@ -52,15 +52,22 @@ namespace Avahi
     public class ClientStateArgs : EventArgs
     {
         private ClientState state;
+        private ErrorCode error;
 
         public ClientState State
         {
             get { return state; }
         }
 
-        public ClientStateArgs (ClientState state)
+        public ErrorCode Error
+        {
+            get { return error; }
+        }
+
+        public ClientStateArgs (ClientState state, ErrorCode error)
         {
             this.state = state;
+            this.error = error;
         }
     }
     
@@ -279,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);
+                }
             }
         }
 
@@ -349,7 +361,7 @@ namespace Avahi
         private void OnClientCallback (IntPtr client, ClientState state, IntPtr userData)
         {
             if (StateChanged != null)
-                StateChanged (this, new ClientStateArgs (state));
+                StateChanged (this, new ClientStateArgs (state, LastError));
         }
 
         private int OnPollCallback (IntPtr ufds, uint nfds, int timeout) {
@@ -363,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);