开发者

Changing the Property of a Brush Colour through a Thread

I have a Brush Colour which I would like to change every so and so on a thread.

static SolidColorBrush myBrush;

Thread changeColourThread = new Thread(changeColour);

static void changeColour()
{
       myBrush = new SolidColorBrush(Color.FromArgb(255, 33, 96, 22));
}
开发者_StackOverflow中文版

This returns an UnauthorizedAccessException, what's the best way to handle this?

Thanks


You're going to need to use the dispatcher, try this thread.


It looks like creating SolidColorBrush has to be done in UI thread (no idea why). I had similar problem and my solution is to return just Color and then use Converter to convert it into a Brush in .xaml.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜