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

How to emit signals with dbus-sharp?

Open chmorgan opened this issue 11 years ago • 1 comments

I must be missing something, how would I emit a signal from dbus-sharp? I looked through the examples but don't see anything that looks analogous.

chmorgan avatar Aug 29 '14 17:08 chmorgan

And I'll answer my own question:

  • Add an event to your dbus object class, like:
public class Blah : MarshalByRefObject
{
    public event MyEventHandler OnEvent;

    public void EventHandler()
    {
        if(OnEvent != null) { OnEvent(); }
    }
}
  • Run 'dbus-monitor' to watch the dbus activity on your system
  • Call Blah's EventHandler() method and see that the 'OnEvent' signal was sent from your dbus object.

chmorgan avatar Aug 29 '14 18:08 chmorgan