OSDN Git Service

ファイル操作関連をDocumentExtendクラスに分離した
[fooeditengine/FooEditEngine.git] / WPF / Test / MainWindow.xaml.cs
index eeabf01..5ed1212 100644 (file)
@@ -25,6 +25,7 @@ namespace Test
     /// </summary>
     public partial class MainWindow : Window
     {
+        System.Threading.CancellationTokenSource cancleTokenSrc = new System.Threading.CancellationTokenSource();
         public MainWindow()
         {
             InitializeComponent();
@@ -38,7 +39,7 @@ namespace Test
 
         void MainWindow_Closed(object sender, System.EventArgs e)
         {
-            this.fooTextBox.Document.Cancel();
+            this.cancleTokenSrc.Cancel();
         }
 
         void fooTextBox_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
@@ -120,7 +121,7 @@ namespace Test
             bool result = (bool)ofd.ShowDialog(this);
             if (result == true)
             {
-                await this.fooTextBox.Document.LoadAsync(ofd.FileName, Encoding.Default);
+                await this.fooTextBox.Document.LoadAsync(ofd.FileName, Encoding.Default,this.cancleTokenSrc);
                 this.fooTextBox.Refresh();
             }
         }
@@ -190,7 +191,7 @@ namespace Test
             bool result = (bool)sfd.ShowDialog(this);
             if (result == true)
             {
-                await this.fooTextBox.Document.SaveAsync(sfd.FileName,Encoding.Default,"\r\n");
+                await this.fooTextBox.Document.SaveAsync(sfd.FileName,Encoding.Default,"\r\n",cancleTokenSrc);
                 MessageBox.Show("complete");
             }
         }