dbus-sharp icon indicating copy to clipboard operation
dbus-sharp copied to clipboard

Add Connection.(Un)TrapSignals

Open hyperair opened this issue 14 years ago • 1 comments

A TrapSignals and UntrapSignals is needed for the implementation of certain DBus protocols like Avahi, where signals can come in between getting an ObjectPath as the return value of a function call and connecting handlers to its signals. Example use-case, as found in Mono.Zeroconf:

        DBusManager.Bus.TrapSignals ();

        lock (this) {
            if (resolver != null) {
                throw new InvalidOperationException ("The service is already running a resolve operation");
            }

            ObjectPath path = DBusManager.Server.ServiceResolverNew (AvahiInterface, AvahiProtocol, 
                Name ?? String.Empty, RegType ?? String.Empty, ReplyDomain ?? String.Empty, 
                AvahiProtocol, LookupFlags.None);

            resolver = DBusManager.GetObject<IAvahiServiceResolver> (path);
        }

        resolver.Failure += OnResolveFailure;
        resolver.Found += OnResolveFound;

        DBusManager.Bus.UntrapSignals ();

hyperair avatar Nov 07 '11 02:11 hyperair

This solved me a lot of problems. It should be merged to master

ghost avatar Dec 12 '16 17:12 ghost