質問編集履歴
1
連続発火イベント対策
title
CHANGED
File without changes
|
body
CHANGED
@@ -44,4 +44,34 @@
|
|
44
44
|
////
|
45
45
|
```
|
46
46
|
|
47
|
-
よろしくお願いします。
|
47
|
+
よろしくお願いします。
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
///追記FileSystemWatcherイベント連続発火対策について
|
54
|
+
|
55
|
+
```C#
|
56
|
+
private private ImagePreview imagewindow= null;//サブウィンドウをnullに
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
private void OnChanged(object sender, FileSystemEventArgs e)//FileSystemWatcherイベント発火
|
61
|
+
{
|
62
|
+
Dispatcher.BeginInvoke((Action<FileSystemEventArgs>)OnChangedInMainThread, e);//これ(メイン処理)を実行
|
63
|
+
}
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
private void OnChangedInMainThread(FileSystemEventArgs e)//メイン処理
|
68
|
+
{
|
69
|
+
if (imagewindow== null)//imagewindowがnullだった場合imagewindowを開く
|
70
|
+
{
|
71
|
+
imagewindow= new ImagePreview ();
|
72
|
+
imagewindow.Closed += (fomsend, err) => { imagewindow= null; };//ImagePreview が閉じたことを通知してimagewindowをnullにする
|
73
|
+
imagewindow.Owner = this;//親子関係
|
74
|
+
imagewindow.Show();
|
75
|
+
}
|
76
|
+
}
|
77
|
+
```
|