[Vala] threads in vala



Hello

I try to write a program with vala to display some network packets with
pcap,

I use async method to the infinite loop however it still cause the program
to stuck.

Does the async method is not a real thread?

if I call to yield inside the pcap loop inside the async method I get an
error:  "yield expression not available outside async method"

example code:

public void on_btn_click (Button b)
    {

          fill_list_with_pcap.begin((obj, res) => {
            fill_list_with_pcap.end(res);
            loop.quit();
        });
        loop.run();
}

private async void fill_list_with_pcap() {
     cap.loop(-1,(header, data) => {
          yield sleep_async (100, new Cancellable ());
      }
}

compile with vala 0.18.1


Thanks
Nadav

-- 
הבלוג שלי:
http://nadavvin.com


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