문제

플러그인을 개발하는 데 사용하기 위해 Bare Bones 앱을 만들려고합니다. 워크 벤치가 필요하지 않습니다.

Title1 대화 상자 아래에 표시되지만 Title2는 결코하지 않습니다.

두 번째를 보여주기 위해서는 무엇을해야합니까?

public class BareBonesApp extends AbstractApplication
{
    public Object start(IApplicationContext context) throws Exception
    {
        Display display = PlatformUI.createDisplay();

        MessageDialog.openWarning(null, "title1", "message1");

        display.asyncExec(new Runnable()
        {
            public void run()
            {
                MessageDialog.openWarning(null, "title2", "message2");
            }
        });

        return null;
    }
}
도움이 되었습니까?

해결책

디스플레이에는 동기화, 비동기 또는 Specifc 시간 (display.timerexec)에 실행 해야하는 런 가능성에 대한 큐가 다릅니다. Display.ReadandDispatch가 모든 이벤트를 발송했을 때, 먼저 동기식 큐의 런닝 가능성이 실행 된 다음 Async-queue가 비워지고 그 후 TimereXec Runnables가 실행됩니다.

display.syncexec과 display.asyncexec의 유일한 차이점은 SynCexec 메소드가 디스플레이 스레드에서 실행할 수있는 것을 기다립니다. display.asyncexec은 단순히 런 가능성을 대기하고 계속합니다.

따라서 "Title2"가 나타나지 않으면 응용 프로그램이 디스플레이 루프를 실행하지 않습니다.

Display display = new Display(); // this thread should be the only one that creates a display instance
while (someCondition) {
  if (!display.readAndDispatch())
    display.sleep();
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top