From 0de4ce081400a99c7c7fdca0bdb18e27261fb31f Mon Sep 17 00:00:00 2001 From: Thomas Bolon Date: Thu, 21 Sep 2023 11:02:47 +0200 Subject: [PATCH 1/2] add clarifications about Control.Invoke behavior when an EventHandler delegate is used --- xml/System.Windows.Forms/Control.xml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/xml/System.Windows.Forms/Control.xml b/xml/System.Windows.Forms/Control.xml index 765f91b4e31..bf166523218 100644 --- a/xml/System.Windows.Forms/Control.xml +++ b/xml/System.Windows.Forms/Control.xml @@ -7899,7 +7899,12 @@ MyControl.Font = New Font(MyControl.Font, _ > [!NOTE] > In addition to the property, there are four methods on a control that are thread safe: , , , and if the handle for the control has already been created. Calling before the control's handle has been created on a background thread can cause illegal cross thread calls. For all other method calls, you should use one of the invoke methods to marshal the call to the control's thread. - The delegate can be an instance of , in which case the sender parameter will contain this control, and the event parameter will contain . The delegate can also be an instance of , or any other delegate that takes a void parameter list. A call to an or delegate will be faster than a call to another type of delegate. + The delegate can be an instance of , in which case the parameters will depend on the `args` value: + In case no parameters are passed, the sender parameter will contain this control and the event parameter will contain . + When one single parameter is passed, the sender parameter will contain the first args element and the event parameter will contain . + If more than one parameter are passed, the sender parameter will contain the first element from `args`, and the parameter will contain the second element. + + A call to an or delegate will be faster than a call to another type of delegate. > [!NOTE] > An exception might be thrown if the thread that should process the message is no longer active. From 3f0fbeca3a19fdf21fb7f1a9a55dd05162b7fa5d Mon Sep 17 00:00:00 2001 From: Thomas Bolon Date: Sat, 23 Sep 2023 13:48:13 +0000 Subject: [PATCH 2/2] applied suggestion --- xml/System.Windows.Forms/Control.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/xml/System.Windows.Forms/Control.xml b/xml/System.Windows.Forms/Control.xml index bf166523218..b331c007713 100644 --- a/xml/System.Windows.Forms/Control.xml +++ b/xml/System.Windows.Forms/Control.xml @@ -7900,9 +7900,9 @@ MyControl.Font = New Font(MyControl.Font, _ > In addition to the property, there are four methods on a control that are thread safe: , , , and if the handle for the control has already been created. Calling before the control's handle has been created on a background thread can cause illegal cross thread calls. For all other method calls, you should use one of the invoke methods to marshal the call to the control's thread. The delegate can be an instance of , in which case the parameters will depend on the `args` value: - In case no parameters are passed, the sender parameter will contain this control and the event parameter will contain . - When one single parameter is passed, the sender parameter will contain the first args element and the event parameter will contain . - If more than one parameter are passed, the sender parameter will contain the first element from `args`, and the parameter will contain the second element. +- If no parameters are passed, the sender parameter will contain this control and the event parameter will contain . +- When a single parameter is passed, the sender parameter will contain the first args element and the event parameter will contain . +- If more than one parameter is passed, the sender parameter will contain the first element from `args`, and the parameter will contain the second element. A call to an or delegate will be faster than a call to another type of delegate.