如何从FileSystemEventArg OnChange方法中关闭动态创建的表单? [英] How do I close the dynamically created form from within the FileSystemEventArg OnChange method?

查看:68
本文介绍了如何从FileSystemEventArg OnChange方法中关闭动态创建的表单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以从ButtonOnClick方法中关闭此表单,但是当我从FileSystemWatcher OnChange事件处理程序尝试相同时,表单不会关闭..任何帮助将不胜感激。

I am able to close this form from within the ButtonOnClick method but when I try the same from FileSystemWatcher OnChange event handler the form does not close.. Any help would be greatly appreciated.

推荐答案

文件系统观察程序(FSW)没有在用户界面线程上引发它的事件。当没有设置SynchronizingObject属性并且你需要在MainForm构造函数中添加一个赋值时它会这样做。



当在Visual Studio窗体中创建FSW时设计器自动生成设置SynchronizingObject属性所需的代码。试一试,看看。



Alan。
The file system watcher (FSW) is not raising it's events on the user interface thread. It does this when the SynchronizingObject property is not set and you'll need to add an assignment into the MainForm constructor.

When a FSW is creating within the Visual Studio Form's designer the required code to set the SynchronizingObject property is automatically generated. Try it and see.

Alan.


这篇关于如何从FileSystemEventArg OnChange方法中关闭动态创建的表单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆