Created
January 30, 2013 03:07
-
-
Save anonymous/4670269 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Net; | |
using System.Threading; | |
using System.Threading.Tasks; | |
using System.Windows; | |
using System.Windows.Controls; | |
using System.Windows.Documents; | |
using System.Windows.Input; | |
using System.Windows.Media; | |
using System.Windows.Media.Animation; | |
using System.Windows.Shapes; | |
namespace SilverAsync | |
{ | |
public partial class MainPage : UserControl | |
{ | |
public MainPage() | |
{ | |
InitializeComponent(); | |
} | |
private void Button_Click_1(object sender, RoutedEventArgs e) | |
{ | |
Task.Factory.StartNew(() => | |
{ | |
//Poll for weather here! | |
var t = 0; | |
while (true) | |
{ | |
t += 1; | |
Dispatcher.BeginInvoke(() => textbox1.Text = t.ToString()); | |
Thread.Sleep(1000); | |
} | |
}); | |
Task.Factory.StartNew(() => | |
{ | |
//Check the CPU here! | |
var t = 100; | |
while (true) | |
{ | |
t += 1; | |
Dispatcher.BeginInvoke(() => textbox2.Text = t.ToString()); | |
Thread.Sleep(1000); | |
} | |
}); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment