try
    whichscreen = max(Screen('Screens'));
    [myscreen, screen_rect] = Screen('OpenWindow', whichscreen);
    Screen('FillRect', myscreen, 0, CenterRect([0, 0, 100, 100], ...
        screen_rect));
    priorityLevel=MaxPriority(window);
    Priority(priorityLevel);
    t0 = Screen('Flip', myscreen);
    Screen('Flip', myscreen, t0 + 1);
    Priority(0);
    Screen('CloseAll');
catch
    Screen('CloseAll')
    rethrow(lasterror)
end