Created
March 28, 2012 00:26
-
-
Save duraz0rz/2222025 to your computer and use it in GitHub Desktop.
Modified Threading
This file contains hidden or 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.Text; | |
using System.Windows; | |
using System.Windows.Controls; | |
using System.Windows.Data; | |
using System.Windows.Documents; | |
using System.Windows.Input; | |
using System.Windows.Media; | |
using System.Windows.Media.Imaging; | |
using System.Windows.Navigation; | |
using System.Windows.Shapes; | |
using System.Threading; | |
namespace WpfApplication1 | |
{ | |
/// <summary> | |
/// Interaction logic for MainWindow.xaml | |
/// </summary> | |
public partial class Window1 : Window | |
{ | |
public delegate void DrawEllipses(); | |
private Thread _tServer; | |
public Window1() | |
{ | |
InitializeComponent(); | |
canvas.Dispatcher.BeginInvoke(new DrawEllipses(sThread), System.Windows.Threading.DispatcherPriority.Normal, new Object[] { }); | |
System.Diagnostics.Debug.WriteLine("Main thread!"); | |
} | |
private void sThread() | |
{ | |
Ellipse e = new Ellipse(); | |
e.Fill = new SolidColorBrush(Colors.Black); | |
e.Height = 20; | |
e.Width = 20; | |
if (canvas.Dispatcher.CheckAccess()) | |
{ | |
canvas.Children.Add(e); | |
Canvas.SetLeft(e, 100); | |
Canvas.SetTop(e, 100); | |
} | |
System.Diagnostics.Debug.WriteLine("Spawned thread!"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment