-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Description
Description
We are using a system that exposes UI interface using COM objects. It is an external application so I cannot send a minimal reproduction source code of a problem. I will try to explain the whole workflow.
Background information
There is an application interface (COM) that exposes event.
Event declaration in the App interface:
event _IApplicationEvents_StatusBarEventEventHandler StatusBarEvent;Delegate definition:
public delegate void _IApplicationEvents_StatusBarEventEventHandler([In][MarshalAs(UnmanagedType.BStr)] string Text, [In] BoStatusBarMessageType messageType);There is also a StatusBarControl that allows us to set up the ProgressBarMessage:
application.StatusBar.SetText(“some text”);When we set the text to the status bar Event is fired.
Reproduction Steps
UseCase: When the StatusBarEvent fires with text equal to “crush” we want to change this to "****" on the status bar
EventHandler implementation:
public override void OnStatusBarDisplayed(string text, BoStatusBarMessageType messageType)
{
if (text.Equals("crush",StringComparison.CurrentCultureIgnoreCase))
{
application.StatusBar.SetText("*****");
}
}I will provide some screenshots of the debugging session:
- Set "crush" to the status bar.

- We get the Event notification and call the setText("****").
- System freezes. We can see that the event handler thread freezes on the set text method.

- We can see that in the separate thread invoking a method the foreach loop of _delegateWrapper.

Expected behavior
What should happen: this thread @29816 should invoke this method and Call the OnStatusBarDisplayed event again. This is working correctly when running in the .net framework.
Below is the same call stack of the .net framework debugging session. 
Calling SetText in another thread is not an option for us.
Actual behavior
System freezes. We can see that the event handler thread freezes on the set text method. 
Regression?
This is working correctly when running in the .net framework.
Known Workarounds
Calling SetText in another thread but this is not an option for us.
Configuration
.NET 6.0
Windows 11
x64
Other information
No response