模拟手动启动 [英] Simulate manual start
问题描述
在VB.Net Visual Studio 2005中
程序根据启动方式的不同而有所不同.
我在同一程序上有两种启动方法:
-手动启动按钮.
-从IO.FileSystemWatcher之类的事件开始
手动启动时,一切工作都像您想做的那样.
在FileSystemWatcher上,我遇到三个问题:
-表单中的绘画事件不会显示所有详细信息.
-DoEvents将不执行事件.
-MSScriptControl.ScriptControlClass将使用对话框形式进行超时.
In VB.Net Visual Studio 2005
Program acts different depending how they were started.
I have two start methods on the same program:
- Manually start on a button.
- Start on an event like IO.FileSystemWatcher
On the manual start everything works like a want it to do.
On the FileSystemWatcher start I have three problems:
- The paint event in a form does not shows all details.
- The DoEvents will not do events.
- The MSScriptControl.ScriptControlClass will do timeouts with a dialog form.
Is there a way to simulate the manual start when system starts on a event or do I have to change something else?
推荐答案
简短版本:调用"
长版:Google关于线程. FileSystemWatcher不在UI线程上,因此无法处理UI事件.
Short version: "Invoke"
Long version: Google about threads. FileSystemWatcher is not on the UI thread, so it cannot process UI events.
感谢OriginalGriff!
调用"将我引向一个更简单的解决方案:
WatchFolder.SynchronizingObject = Me
Wich是解决线程问题的简单方法.
Thanks OriginalGriff!
The "Invoke" lead me into an easier solution:
WatchFolder.SynchronizingObject = Me
Wich was a simple way to fix the thread problem.
这篇关于模拟手动启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!