我正在编写一个小型WPF应用程序,它会产生一些线程来对网站页面进行压力测试.我想在我从主WPF线程手动启动的线程的状态的wpf形式的文本框中输出一些信息.我有点期望WPF具有相同的功能,只要通过以下方式将我的线程同步回GUI线程:
if(this.InvokeRequired)
this.Invoke(ProcessState);
Run Code Online (Sandbox Code Playgroud)
但是WPF中没有任何类型的东西......在WPF中从非gui线程输出的选项是什么?
编辑:
现在的问题似乎是事实,我不能来检查方法CheckAccess()中的Dispatcher我控制的对象.我正在运行.net和VS 2008 SP1的3.5版本.
这是我的Dispatcher Class的完整元数据(F12就可以了):
using MS.Internal.WindowsBase;
using System;
using System.ComponentModel;
using System.Security;
using System.Threading;
namespace System.Windows.Threading
{
// Summary:
// Provides services for managing the queue of work items for a thread.
public sealed class Dispatcher
{
// Summary:
// Gets the System.Windows.Threading.Dispatcher for the thread currently executing
// and creates a new System.Windows.Threading.Dispatcher if one is not already
// associated with the thread.
//
// Returns:
// The dispatcher …Run Code Online (Sandbox Code Playgroud)