UI does not show until screensaver is closed

I have a little app that just shows a menu bar and some items, but I need to wait for the screensaver to to turn on and then close it to see the app.
The splash screen however gets show. I am also calling show() on the screen:

Any idea?


function Main() as void
	print "Main() called"
	prepareAndshowChannel()
end function

sub prepareAndshowChannel()
	print "prepareAndshowChannel() called"
	m.MainScreen = CreateObject("roSGScreen")
	MainScreen = m.MainScreen
	m.port = CreateObject("roMessagePort")
	m.MainScreen.setMessagePort(m.port)
	m.ApplicationScreen = m.MainScreen.CreateScene("ApplicationScreen")
	print "MainScreen and ApplicationScreen prepared"
	m.MainScreen.show()

	while(true)
		msg = wait(0, m.port)
		msgType = type(msg)
		if msgType = "roSGScreenEvent"
			if msg.isScreenClosed() then return
		end if
	end while

end sub

I had an error in my code which I did not see in the console.