[Vala] Pass params through threads_add_idle()



Hi all,
I'm trying to pass a parameter to a function that I call through threads_add_idle().
But threads_add_idle() obviously accepts only a SourceFunc.
I can't pick up the data from a global variable. So I tried using closures from where I'd pass the needed 
parameter:
 
private void ThreadedFunc(uint 8 byte)
{
  Gdk.threads_add_idle(()=>
  {
    GuiWorker(byte);
    return false;
  });
}

But then the class of GuiWorker is not instantiated, so I get an assertion during runtime (self != null). If 
I don't try to pass the parameter and just pass 'GuiWorker' to threads_add_idle() directly (given 'GuiWorker' 
doesn't take any params then), then the instance does exist.

Before that, when I used the deprecated methods Gdk.threads_enter() and Gdk.threads_leave(), I could help 
myself by doing whatever I wanted in between. But how can I work with threads_add_idle() now? The vala 
bindings omit its second parameter 'data', so I'd be glad if you could tell me how do it 'the right way'.

Thanks a bunch.

gilzad


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]