Erm what do you mean by "networking before waitevent call"
There is nothing before it.
In an event driven mainloop everything is controlled through an event, there is nothing "outside" of it as the amount of times the stuff outside would be run is totally out of control as any mousemove would cause it to run again.
Networking normally would be done in TimerEvent for example.
And "After the waitevent call it draws some stars in event_gadgetpaint to a canvas" sounds quite strange as well.
Does your code structure look like:
local id:int
Repeat
id = waitevent()
select id
case EVENT_GADGETREPAINT
' Do the repaint stuff here
case EVENT_TIMERTICK
' Do the networking here
...
end select
Forever
and the event_gadgetrepaint has logically the regular routine to set the canvas to which it is rendered etc, otherwise you try to draw to NULL which will bomb