Disable All Events on a Windows Form

后端 未结 5 791
忘了有多久
忘了有多久 2021-01-19 15:21

Is there any way to temporarily disable ALL events on an windows form?

I have situation where processing on a secondary thread is being corrupted by events on the

5条回答
  •  [愿得一人]
    2021-01-19 16:06

    Blocking events on a form is effectively freezing the UI. Events occur as part of standard message handling in the message pump - stopping events would freeze the UI.

    It would be better to disable UI features while your work is processing (such as disabling the individual buttons, etc), then re-enable them when it completes. This will allow normal events to occur, but prevent the user from triggering a button click, etc.

提交回复
热议问题