Skip to content
This repository has been archived by the owner on Nov 8, 2022. It is now read-only.

Connection.GetObject blocked in signal handler #61

Open
pwik opened this issue Feb 3, 2017 · 1 comment
Open

Connection.GetObject blocked in signal handler #61

pwik opened this issue Feb 3, 2017 · 1 comment

Comments

@pwik
Copy link

pwik commented Feb 3, 2017

Hey,

Getting an object inside a signal handler seems to block execution on the main thread when running an Iterate loop inside a separate thread. Example:

    class MyClass
    {
        Connection connection;
        SomeObject someObject;

        public MyClass()
        {
            connection = Bus.System;

            new Thread(new ThreadStart(() =>
            {
                while (connection.IsConnected)
                {
                    connection.Iterate();
                }
            })).Start();

            someObject = connection.GetObject<SomeObject>(bus_name, objpath...);

            someObject.Callback += () =>
            {
                SomeObject2 so2 = connection.GetObject<SomeObject2>(bus_name, path...);

            }
        }
    }

When the someObject.Callback handler is called the main thread stops when trying to get the SomeObject2 object. My solution to this is to create a new thread in the signal handler and from there access SomeObject2. That seems to work just fine. Am I missing something?

Running in Mono 4.6.2 on Ubuntu 16.04.

@anthonynovatsis
Copy link

Have also observed this issue and was wondering whether there is an alternative to the workaround proposed above?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants