안녕하세요, GUI를로드하는 동안 백그라운드 작업을 수행하기 위해 스레드를 만들어야하는 응용 프로그램을 작성했습니다. 나는이 오류 주위에 방법을 찾을 수 있습니다 할 상관없이 그러나 :Vala 스레딩 : 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 너무 많이 수행하지만, 발라 정확히 가장 인기있는 언어가 아닙니다. 어떤 도움이 필요합니까?
감사합니다. 나는 당신의 픽스를 시도했지만 몇 가지 오류를 던지기는했지만 다음을 수행하여이를 우회 할 수 있었다. 오류 : 'void'는 지원되는 제네릭 형식 인수가 아니며 '?'를 사용한다. 상자 값 유형 ' 수정 :'Thread thread = new Thread .try ("Conntections Thread.",() => {devices_online (listmodel); return null;});' –