So basically I have a console app on which I’m executing a c++ opengl context through a wrapper. The context needs to be updated continuously so it updates inside a while loop. Everything works great except I need to separate the while loop in another thread so that it doesnt block the rest of the application. so basically something like:
Something like a Dispatcher in WPF or Forms. How would this be possible?
Raise an event from the background thread to update the UI.
Do the other work inside the loop. Typical game stuff.


As you get more advanced, you might introduce a dispatcher queue in the loop.
As you get more more advanced, you might introduce seperate threads to do other tasks (not UI), and then queue the results back to the main loop.
Its a library that will be implemented on other projects so basically the “Update” function will be provided from outside.
Any more info on creating a dispatcher queue?
I recommend you look at async await. It lets you call a function that doesn’t block. Behind the scenes it’s using a thread, but it manages it for you.
C# devs
null reference exceptions

source

Categories: .NetCodingCsharpTech