views:

18

answers:

1

Hi! I want to have a thread, that polls the webservice. Howerver the thread doesnt work ...

xxx.xaml.cs:

public class Alpha:Page
    {

        // This method that will be called when the thread is started
        public void polling()
        {
            while (true)
            {
                Thread.Sleep(1000);
                //MessageBox.Show("polling");
                Gamedetails_Player2.show();

            }
        }
    };

class ...:Page

public Gamedetails_Player2()
        {


            // Required to initialize variables
            InitializeComponent();


            Alpha oAlpha = new Alpha();
            Thread poll = new Thread(oAlpha.polling);
            poll.Start();


            MessageBox.Show("polling started"+poll.IsAlive);
            //oAlpha.polling();
            //polling();

        }
public static void show(){MessageBox.Show("running");}
}

My Problem is that the Thread is not working ... it shows alive but it makes nothing... when i call it directly it works but i want to have it in as a thread. Im looking forward for answeres

+1  A: 

Try using a BackgroundWorker Here you will find documentation how to implement this.

rdkleine