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

Author Topic: Window doesn't open by starting a new Thread  (Read 4527 times)

0 Members and 1 Guest are viewing this topic.

Ninjasturm

  • Newbie
  • *
  • Posts: 16
    • View Profile
Window doesn't open by starting a new Thread
« on: October 20, 2010, 07:17:47 pm »
Hello Com,

when i try to start a new Thread and open a new window the window
doesn't show anything.

Here the source from the thread:

Code: [Select]

void Network(void*)
{
    unsigned int Port = 2435;
    // Ask for server address
    sf::IPAddress ServerAddress;
    do
    {
        ServerAddress = "localhost";
    }
    while (!ServerAddress.IsValid());
    std::cin.ignore(10000, '\n');

    // Create a socket for exchanging data with the server
    sf::SocketTCP Socket;

    // Connect to the server
    if (Socket.Connect(Port, ServerAddress) != sf::Socket::Done)
        return;

    // Send messages until we are disconnected
    bool Connected = true;
    /*
    while (Connected)
    {
        // Let the user write a message
        std::string Message;
        std::cout << "Say something to the server : ";
        std::getline(std::cin, Message);

        // Send it to the server
        sf::Packet Packet;
        Packet << Message;
        Connected = (Socket.Send(Packet) == sf::Socket::Done);
    }
    */

    // Close the socket
    Socket.Close();
}

And now some important main source:

    // Einstellungen laden
    int VideoX = 1024;
    int VideoY = 768;
    sf::Thread NetworkThread(&Network);
    NetworkThread.Launch();
    ifstream LoadConfig("Data\\Config.txt");
    // LoadConfig >> VideoX;
    // LoadConfig >> VideoY;
    // Fenster erstellen
    sf::RenderWindow App(sf::VideoMode(VideoX, VideoY, 32), "Window", sf::Style::Close);

Ninjasturm

  • Newbie
  • *
  • Posts: 16
    • View Profile
Window doesn't open by starting a new Thread
« Reply #1 on: October 20, 2010, 07:47:57 pm »
:oops: I have to start Network after the Window.