How to use thread for never returned function in C#

126 Views Asked by At

I am new in C# and I want to use thread because in the following code I want to call Glut.glutMainLoop(); function in for loop but this function never return and it stopped. I think I can use thread.But I dont know how can I do that. Or is there any other solution? Any help would be much appreciated.

 static void Main()
            {

               int i;
                 ...
                 ...
                 ...

                  for (i=0 ; i<=10 ; i++) {


                  Glut.glutMainLoop();

               }

          }
1

There are 1 best solutions below

0
On

Having looked at the documentation for glutMainLoop, it seems this method initiates Glut's message pump. And that's why it will never return.

It seems to me that you shouldn't be using threads. Once you initiate Glut, it will take over the application and take care of the application's life-cycle for you.

All your logic should go into the callbacks that Glut will call. See:

It will call as necessary any callbacks that have been registered.