  =======================
  'START WINDOW IN THREAD
  =======================

  function WinStart(sys*dat) as sys external
  '=========================================
  finit
  active=1
  zstring* cmdline
  &cmdline=GetCommandLine
  sys instance=GetModuleHandle 0
  WinMain instance,0,cmdline,SW_NORMAL
  active=0
  end function
  
  sub WinFinish() external
  '=======================
  terminate
  end sub

  #ifndef THREADED_WINDOW

  sub start() external
  WinStart dat
  end sub

  sub Finish() external
  WinFinish
  end sub
    '
  #else 'THREADED WINDOW
  '
  '
  sys hWinThread, hWinThreadId
  '
  sub start() external
  hWinThread=CreateThread 0, 0, @WinStart, @dat, 0, @hWinThreadId
  sleep 100
  end sub
  '
  sub finish() external
  WaitForMultipleObjects 1, @hWinThread, 1, -1 ' -1 INFINITE wait
  CloseHandle hWinThread
  WinFinish
  end sub
  '
  #endif

  
 