文件系统监视程序C# [英] File System Watcher C#

查看:67
本文介绍了文件系统监视程序C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

伙计们,我正在使用vs2005,我有一个filesystemwatcher,在filesystemwatcher的change事件中,我正在显示一个表单,但是问题是,每当触发change事件时,表单都会显示并被吊死,不知道为什么?有人可以帮我吗?这是代码

hey guys, i''m using vs2005, and i have got a filesystemwatcher, and in the change event of filesystemwatcher i''m displaying a form, but the problem is that whenever the change event is fired, the form get displayed and it gets hanged, don''t know why? can anyone help me please? here is the code

推荐答案

那是因为事件不是异步引发的,所以您必须使用Form.Show而不是Form.ShowDialog或启动一个新线程在其中显示表单并执行您喜欢的任何工作.如果您使用新线程,请记住该单元房必须是STA.
Thats because the events are not raised asynchronously, so you''ll have to either use Form.Show instead of Form.ShowDialog or start a new thread where display the form and do any work you like. If you make use of a new thread remember the apartment must be STA.


由于您是在单个线程中运行应用程序,因此表单本身可能会阻止初始化子表单.首先尝试初始化.
Since you are running the application in a single thread, the form itself could block the initialization child form. Try to initialize first of all.


这篇关于文件系统监视程序C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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