# How to make GLFW window non blocking

**URL:** <https://discourse.julialang.org/t/how-to-make-glfw-window-non-blocking/64804>\
**Category:** Visualization\
**Created:** [July 17, 2021, 10:02am UTC](https://discourse.julialang.org/t/how-to-make-glfw-window-non-blocking/64804 "2021-07-17T10:02:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jakub\_Mitura](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jakub_mitura/32/19496_2.png) [@Jakub\_Mitura](https://discourse.julialang.org/u/Jakub_Mitura)\
**Post date:** [July 17, 2021, 10:02am UTC](https://discourse.julialang.org/t/how-to-make-glfw-window-non-blocking/64804/1 "2021-07-17T10:02:25Z")

</div>

Hello I am creating some openGL GUI and I have probably simple to solve problem - I want to have the rendering loop non blocking i.e so for example I will be able to run the openGL app and make it possible to 1) respond to keyboard and mouse inputs 2) respond to the inputs from REPL now when I start While loop for obvious reason the REPL is blocked and can not be used.  
I tried using @async but in this case for some reason it closes immidiately  
I tried using Distributed worker and @spawnat 2 … but in this case the input from GUI like for example closing the window do not work

my simple rendering/event loop

```julia
function sipmpleeventLoop(window)
    try
        while !GLFW.WindowShouldClose(window)
            GLFW.PollEvents()
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        end
    finally
        GLFW.DestroyWindow(window)
    end

end

```

thanks for help !!

---

<div class="post-metadata">

**Author:** ![Jakub\_Mitura](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jakub_mitura/32/19496_2.png) [@Jakub\_Mitura](https://discourse.julialang.org/u/Jakub_Mitura)\
**Post date:** [July 18, 2021, 4:15am UTC](https://discourse.julialang.org/t/how-to-make-glfw-window-non-blocking/64804/2 "2021-07-18T04:15:57Z")

</div>

Ok I figured it out 🙂

```julia
	t = @task begin;
		while(!GLFW.WindowShouldClose(window))
		 sleep(0.1);
		 glClear()             
		 # Poll for and process events
		  GLFW.PollEvents()
		end
		end
	schedule(t)

```
