3 using System.Windows.Controls;
4 using System.ComponentModel;
13 public partial class McrNews : UserControl
15 String
_url =
"http://dataweb.isis.rl.ac.uk/mcr/mcrnews.txt";
16 BackgroundWorker
_worker =
new BackgroundWorker();
22 InitializeComponent();
28 _worker.RunWorkerAsync();
30 _timer =
new System.Timers.Timer();
32 _timer.Elapsed +=
new System.Timers.ElapsedEventHandler(
_timer_Elapsed);
40 _worker.RunWorkerAsync();
46 Action action = delegate()
50 if (!String.IsNullOrEmpty(text) && text != txtNews.Text)
57 this.Dispatcher.Invoke(action);
64 if (String.IsNullOrEmpty(
_url))
return "";
67 WebRequest wr = WebRequest.Create(
_url);
69 using (WebResponse res = wr.GetResponse())
70 using (Stream s = res.GetResponseStream())
71 using (StreamReader sr =
new StreamReader(s))
72 data = sr.ReadToEnd();
System.Timers.Timer _timer
void _worker_DoWork(object sender, DoWorkEventArgs e)
String GetLatestInformation()
void _timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
void UserControl_Loaded(object sender, RoutedEventArgs e)
Interaction logic for McrNews.xaml