2010-06-11 68 views
0

我想要一个线程,即轮询web服务。 Howerver线程不工作...silverlight,xaml,线程问题

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");} 
} 

我的问题是,螺纹是不工作...它表明活着,但它使没有... 时我直接称它有效,但我想把它作为一个线程。 我期待回答

回答

1

尝试使用BackgroundWorker Here你会发现文档如何实现这一点。