开发者

Can SynchronizationContext.Post or .Send lead to exceptions?

开发者 https://www.devze.com 2022-12-23 01:42 出处:网络
I\'ve read all recommended articles on SynchronizationContext, but there is one small question I did not find an answer for.

I've read all recommended articles on SynchronizationContext, but there is one small question I did not find an answer for. In my case I have an event handler that calls a Log() method that outputs text to a TextBox. Log() is called from a WCF service. The event is raised from WCF client instances (threads). Usually, I check Control.InvokeRequired to be sure I am on the correct thread.

开发者_StackOverflow

Do I still need to do that when using SynchronizationContext? In other words, can I always do a .Post() or .Send() even if I'm already on the correct thread?


Using Post or Send if you're already on the correct thread is not necessary, but it will work

0

精彩评论

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

关注公众号