Is it good idea to use “Control.CheckForIllegalCrossThreadCalls = false” [duplicate]

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-28 00:23:53

While it may appear to work most of the time, it is sure to fail every now and then.

If you need to access/modify the UI control from another thread, use Control.Invoke.

Not a good idea to do that.

I believe the preferred method is to check to see if Control.InvokeRequired == true, and if so then use Control.Invoke with the proper delegate, which will marshall the method call onto the UI thread.

Will you write something like below

       try
        {
            Object obj=null;
            var result = obj.ToString();
        }
        catch (Exception )
        {


        }

I am sure your answer would be NO , similar thing is with Control.CheckForIllegalCrossThreadCalls = false, it will just eating exception but present unknown results to your estimated clients

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!