{{fbdoc item="title" value="SCREENSYNC"}}----
Synchronizes display updates with hardware

{{fbdoc item="syntax"}}##
	[[KeyPgDeclare|declare]] [[KeyPgFunction|function]] **Screensync** ( ) [[KeyPgAs|as]] [[KeyPgLong|long]]
##
{{fbdoc item="usage"}}##
	//result// = **Screensync**
##
{{fbdoc item="ret"}}
	Zero if successful, or non-zero if a graphics mode was not previously set.

{{fbdoc item="desc"}}
	This [[GfxLib]] statement stops the execution of the program until the graphics card signals it has ended tracing a frame and is going to start the new one.
	
	If the program uses this small interval of time between frames to redraw the image, the flickering is greatly reduced. In that use, ##**Screensync**## is a reminiscence of QB where there was only that equivalent method (##[[KeyPgWait|WAIT]] &H3DA, 8##) to improve the flickering. It is an empirical method because it only allows to synchronize the beginning of the drawing with the fixed dead time between two frames. To be used occasionally to avoid flickering when only very short time of drawing.
	
	Except the purpose to reduce the flickering, ##**Screensync**## can be also used simply as a method of synchronization of graphic drawing with the screen frame tracing (similarly to statement ##[[KeyPgSleep|Sleep]]##).
	
	The error code returned by ##**Screensync**## can be checked using ##[[KeyPgErr|Err]]## in the next line. The function version of  ##**Screensync**## returns directly the error code as a 32 bit ##[[KeyPgLong|Long]]##.
	
	The use of the QB-compatible form ##[[KeyPgWait|WAIT]] &H3DA, 8## is deprecated.

{{fbdoc item="ex"}}
{{fbdoc item="filename" value="examples/manual/gfx/screensync.bas"}}%%(freebasic)
'main loop
DO
  
  ' do user input
  ' calculate_a_frame
   
  SCREENSYNC
  
  ' draw_ a_ frame  
  
LOOP UNTIL INKEY <> ""
%%


{{fbdoc item="lang"}}
	- Not available in the //[[CompilerOptlang|-lang qb]]// dialect unless referenced with the alias ##**""__Screensync""**##.

{{fbdoc item="diff"}}
	- New to ""FreeBASIC"". 
	- QBasic used ##[[KeyPgWait|WAIT]] &H3DA, 8## for this purpose.

{{fbdoc item="see"}}
	- ##[[KeyPgWait|Wait]]##

{{fbdoc item="back" value="CatPgGfxScreen|Screen Functions"}}