Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Multithreading events don't seem to fire  (Read 1650 times)

0 Members and 1 Guest are viewing this topic.

Aravol

  • Newbie
  • *
  • Posts: 8
    • View Profile
    • Email
Multithreading events don't seem to fire
« on: June 23, 2014, 02:18:34 am »
Currently using SFML 2.1 with .NET 4.5 and the x64 builds.

I've already seen the note on having to set the window active to false in order to get draw events to work properly from multiple threads, but at this point, I'm trying to spawn update events to another thread, so I can follow a similar pattern for both.

However, when running the Dispatch Events from another thread, I seem unable to receive the close event. Below is the minimalist code I could come up with to reproduce the issue

        public static void Main(string[] args)
        {
            var Window = new RenderWindow(new VideoMode(800u, 600u), "");

            Window.Closed += (sender, e) => Window.Close();

            Task.WaitAll(
                Task.Run(() =>
                {
                    while (Window.IsOpen)
                    {
                        Window.DispatchEvents();
                    }
                }));
        }


Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Laurent Gomila - SFML developer

Aravol

  • Newbie
  • *
  • Posts: 8
    • View Profile
    • Email
Re: Multithreading events don't seem to fire
« Reply #2 on: June 23, 2014, 02:58:58 pm »
Well, in all my searching for threads and windows, I hadn't come across the page. Thanks for the quick reply! :)

 

anything