Connection.GetObject blocked in signal handler
Opened this issue · 1 comments
pwik commented
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 commented
Have also observed this issue and was wondering whether there is an alternative to the workaround proposed above?