Skip to content

Instantly share code, notes, and snippets.

Created January 30, 2013 03:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/4670269 to your computer and use it in GitHub Desktop.
Save anonymous/4670269 to your computer and use it in GitHub Desktop.
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