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

Author Topic: Event thread  (Read 1434 times)

0 Members and 1 Guest are viewing this topic.

BlueX

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
Event thread
« on: October 25, 2013, 01:46:54 am »
Hello,

I'm creating a game and i create a thread to handle all events in the game, but the problem is that when i use the thread my aplications freezes and crash, i runed  a debug and i figured that the problem was with the thread. so i did this:

Code: [Select]
//events_thread.launch();
But it still crashing, so i realise that i need to use the event loop in the main fuction, which is game_start.

So my question is why i can't use a event thread? And how much threads can i create?

Thanks.

Here is the code expleined:


Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: Event thread
« Reply #1 on: October 25, 2013, 02:04:10 am »
The code's missing.

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: Event thread
« Reply #2 on: October 25, 2013, 02:32:39 am »
To quote from the official tutorial.

Quote
Events must be polled in the window's thread

This is an important limitation of most OSes: the event loop (more precisely, the pollEvent or waitEvent function) must be called in the same thread that created the window. This means that if you want to create a dedicated thread for event handling, you'll have to make sure that the window is created in this thread too. If you really want to split things between threads, it is more convient to keep event handling in the main thread and move the rest (rendering, physics, logic, ...) to a separate thread instead. This configuration will also be compatible with the other limitation described below.
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

BlueX

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
Re: Event thread
« Reply #3 on: October 25, 2013, 03:29:47 pm »
The code's missing.

There is no need to show the code, i explained everything...

To quote from the official tutorial.

Quote
Events must be polled in the window's thread

This is an important limitation of most OSes: the event loop (more precisely, the pollEvent or waitEvent function) must be called in the same thread that created the window. This means that if you want to create a dedicated thread for event handling, you'll have to make sure that the window is created in this thread too. If you really want to split things between threads, it is more convient to keep event handling in the main thread and move the rest (rendering, physics, logic, ...) to a separate thread instead. This configuration will also be compatible with the other limitation described below.

Thanks i didn't see that in sfml tutorial, thanks a lot :D

 

anything