本文介绍了尝试无法成功使用TaskbarNotifier C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用TaskbarNotifier,这是我的项目中C#中的可换肤的类似于MSN Messenger的弹出窗口,我在TaskbarNotifier随附的cs文件中有问题.

在此行:
SetBounds(WorkAreaRectangle.Right-BackgroundBitmap.Width-17, WorkAreaRectangle.Bottom-1, BackgroundBitmap.Width, 0);

我收到一条错误消息:
跨线程操作无效:从创建该线程的线程之外的线程访问控件''''.

我该如何绕过?我不知道.
谢谢

I am trying to use TaskbarNotifier, a skinnable MSN Messenger-like popup in C# in my project, I have a problem in the cs file that comes with the TaskbarNotifier.

At the line:
SetBounds(WorkAreaRectangle.Right-BackgroundBitmap.Width-17, WorkAreaRectangle.Bottom-1, BackgroundBitmap.Width, 0);

I get an error saying:
Cross-thread operation not valid: Control '''' accessed from a thread other than the thread it was created on.

How can I bypass it? I have no clue.
Thanks

推荐答案

public void MyMethod()
{
    if(!Dispatcher.CurrentDispatcher.CheckAccess())
    {
        Dispatcher.CurrentDispatcher.Invoke((Action)MyMethod, null);
        return;
    }
}



http://msdn.microsoft.com/en-us/library/system. windows.threading.dispatcher.aspx [ ^ ]



http://msdn.microsoft.com/en-us/library/system.windows.threading.dispatcher.aspx[^]



这篇关于尝试无法成功使用TaskbarNotifier C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-26 14:45