让FileSystemWatcher的事件在主UI线程出现 [英] get filesystemwatcher events to occur on main UI thread

查看:155
本文介绍了让FileSystemWatcher的事件在主UI线程出现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我能得到FileSystemWatcher的事件均在主UI线程上发生的?目前的文件更改自己的线程发了

Can i get filesystemwatcher events to occur on the main UI thread ?. Currently file changes are fired off on their own threads.

推荐答案

只需设置的FileSystemWatcher.SynchronizingObject 财产的形式实例。同样的事情,调用的BeginInvoke(),但为你自动完成。样板代码:

Simply set the FileSystemWatcher.SynchronizingObject property to the form instance. Same thing as calling BeginInvoke() but done automatically for you. Boilerplate code:

public Form1() {
    InitializeComponent();
    fileSystemWatcher1.SynchronizingObject = this;
}

这篇关于让FileSystemWatcher的事件在主UI线程出现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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