fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Windows;
  6. using System.Windows.Controls;
  7. using System.Windows.Data;
  8. using System.Windows.Documents;
  9. using System.Windows.Input;
  10. using System.Windows.Media;
  11. using System.Windows.Media.Imaging;
  12. using System.Windows.Navigation;
  13. using System.Windows.Shapes;
  14.  
  15. namespace WpfApplication1
  16. {
  17. /// <summary>
  18. /// MainWindow.xaml の相互作用ロジック
  19. /// </summary>
  20. public partial class MainWindow : Window
  21. {
  22. public MainWindow()
  23. {
  24. InitializeComponent();
  25. }
  26.  
  27. private System.Collections.ObjectModel.ObservableCollection<string> Values;
  28.  
  29. private void Button_Click_1(object sender, RoutedEventArgs e)
  30. {
  31. Values = new System.Collections.ObjectModel.ObservableCollection<string>();
  32.  
  33. list.DataContext = Values;
  34.  
  35. System.Threading.Thread t = new System.Threading.Thread(ThreadDesuyo);
  36. t.Start();
  37. }
  38.  
  39. private void ThreadDesuyo()
  40. {
  41. for (int i = 0; i < 10; i++)
  42. {
  43. list.Dispatcher.BeginInvoke(new TestDelegate(TestMethod), i);
  44. }
  45. }
  46.  
  47. private delegate void TestDelegate(int i);
  48.  
  49. private void TestMethod(int i)
  50. {
  51. this.list.Items.Add(i.ToString());
  52. System.Threading.Thread.Sleep(500);
  53. }
  54. }
  55. }
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty