Thanks a bunch, Luca.
Passing parameters through closures does work using GLib.Idle.add() instead of 
Gdk.threads_add_idle().
 
That helped, thanks again.
 
Best,
gilzad
 
 

Gesendet: Mittwoch, 27. August 2014 um 21:22 Uhr
Von: "Luca Bruno" <lethalma...@gmail.com>
An: "Gilzad Hamuni" <gil...@gmx.net>
Cc: "Vala List" <vala-list@gnome.org>
Betreff: Re: [Vala] Pass params through threads_add_idle()

Use Idle.add.
 
On Wed, Aug 27, 2014 at 8:11 PM, Gilzad Hamuni <gil...@gmx.net> wrote: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
_______________________________________________
vala-list mailing list
vala-list@gnome.org[vala-list@gnome.org]
https://mail.gnome.org/mailman/listinfo/vala-list 
 --
www.debian.org[http://www.debian.org] - The Universal Operating System
_______________________________________________
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list

Reply via email to