0
ちょっと、GUIの読み込み中にバックグラウンドタスクを実行するためにスレッドを作成する必要があるアプリケーションを作成しています。しかし、私はこのエラーを回避する方法を見つけることができませんどんなに:Vala Threading:voidメソッドの呼び出しは式として許可されていません
error: invocation of void method not allowed as expression
Thread<void> thread = new Thread<void>.try("Conntections Thread.", devices_online(listmodel));
ライン問題になっているが、「devices_online」メソッドを呼び出し、新しいスレッドを作成しています。
行なわれている完全なコードは次のとおりです。
try {
Thread<void> thread = new Thread<void>.try("Conntections Thread.", devices_online(listmodel));
}catch(Error thread_error){
//console print thread error message
stdout.printf("%s", thread_error.message);
}
及び方法は次のとおりです。
private void devices_online(Gtk.ListStore listmodel){
//clear the listview
listmodel.clear();
//list of devices returned after connection check
string[] devices = list_devices();
//loop through the devices getting the data and adding the device
//to the listview GUI
foreach (var device in devices) {
string name = get_data("name", device);
string ping = get_data("ping", device);
listmodel.append (out iter);
listmodel.set (iter, 0, name, 1, device, 2, ping);
}
}
アイブ氏はGoogleingあまり行われますがValaのは、まさに最も人気のある言語ではありません。どんな助け?
感謝を。私はあなたの修正を試みましたが、いくつかのエラーをスローしましたが、以下を実行することでこれらを回避することができました: エラー: 'void 'はサポートされているジェネリック型引数ではありません。ボックス値型 ' 修正: 'Thread thread = new Thread .try(" Conntections Thread。 "、()=> {devices_online(listmodel); return null;});' –