Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5978283
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:29:37+00:00 2026-05-22T21:29:37+00:00

I’m currently working on a project which allows me to compare some game-dedicated artificial

  • 0

I’m currently working on a project which allows me to compare some game-dedicated artificial intelligences (which are C# classes) by making them play ones against the others. The project includes an OpenGL animation to see the matchs between these classes.

So basically I have a Form containing the OpenGL animation, and another Form containing options and info about the comparison. But it seems that my animation Form is making the rest of the project freeze during the calculation time.

Here is the code when I start a match:

        FormGL formGL = new FormGL();
        formGL.Show();


        // Variables declaration
        //
        // Variable declaration

        while (verifVictoire(plateau, _playerTurn) == false && nombreTours < 64)
        {
            if (_playerTurn == 1) _playerTurn = 2;
            else _playerTurn = 1;
            try
            {
                // Calculation part
                if (_playerTurn == 1) resultat = _AIPlayer1.Joue(plateau, _playerTurn);
                else resultat = _AIPlayer2.Joue(plateau, _playerTurn);
                pion = resultat[2] * 16 + resultat[1] * 4 + resultat[0] + 1;
                plateau[resultat[0], resultat[1], resultat[2]] = _playerTurn;
                nombreTours++;

                formGL.affichPion(_playerTurn, pion); // Send the move to display in the animation
                Thread.Sleep(100); // Pause before next move
            }
            catch (IndexOutOfRangeException)
            {
                // Exception management
            }
        }

When I use that code, both of the Forms open, but none of them finish loading before the animation has stopped working. So I can only see the two forms (empty), the animation updates correctly, but any other content (Labels, menus, buttons, …) are invisibles until the animation stops working.
I know that a Thread.Sleep is affecting the current thread and could be the cause, but even if I remove it, the problem still occurs.

The FormGL contains these methods (among others, but I don’t think they could be responsible of this)

public FormGL()
    {
        this.CenterToScreen();
        InitializeComponent();
    }

private void FormGL_Load(object sender, EventArgs e)
    {
        GLPanel.InitializeContexts();
        Gl.glShadeModel(Gl.GL_SMOOTH);
        Gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
        Gl.glClearDepth(1.0f);
        Gl.glEnable(Gl.GL_DEPTH_TEST);
        Gl.glDepthFunc(Gl.GL_LEQUAL);
        GLWindow_Resize(this, null);
        Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT);
    }

public void affichPion(int Player, int Pion)
    {
        if (Pion != 0)
        {
            joueur[Pion - 1] = Player;
            positionJeton[Pion - 1] = Pion;
            GLWindow_Resize(this, null);
            GLPanel.Refresh();
        }
    }

public void GLWindow_Resize(object sender, EventArgs e)
    {
        float aspect = (float)GLPanel.Width / (float)GLPanel.Height; 
        Gl.glMatrixMode(Gl.GL_PROJECTION);
        Gl.glLoadIdentity();
        Gl.glViewport(0, 0, GLPanel.Width, GLPanel.Height);
        Glu.gluPerspective(60, aspect, 1.0, 300);
        Gl.glMatrixMode(Gl.GL_MODELVIEW);
        Gl.glLoadIdentity();

        Glu.gluLookAt(x, y, z, centerX, centerY, centerZ, upX, upY, upZ);
        Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT);
    }

private void FormGL_Resize(object sender, EventArgs e)
    {
        GLWindow_Resize(this, null);
        GLPanel.Refresh();
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T21:29:38+00:00Added an answer on May 22, 2026 at 9:29 pm

    You are not giving the form any time to draw itself.
    Try putting Application.DoEvents() right before sleep.

    However, I would recommend running the while loop on a different thread to avoid this problem in the first place.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.