File tree Expand file tree Collapse file tree 1 file changed +5
-0
lines changed
src/WinRT.Runtime/Interop Expand file tree Collapse file tree 1 file changed +5
-0
lines changed Original file line number Diff line number Diff line change @@ -70,6 +70,11 @@ static int InvokeCallback(ComCallData* comCallData)
70
70
71
71
int hresult ;
72
72
73
+ // We use a thread local static field to efficiently store the state that's used by the callback. Note that this
74
+ // is safe with respect to reentrancy, as the target callback will never try to switch back on the original thread.
75
+ // We're only ever switching once on the original context, only to release the object reference that is passed as
76
+ // state. There is no way for that to possibly switch back on the starting thread. As such, using a thread static
77
+ // field to pass the state to the target context (we need to store it somewhere on the managed heap) is fine.
73
78
fixed ( object * statePtr = & CallbackData . PerThreadObject )
74
79
{
75
80
CallbackData callbackData ;
You can’t perform that action at this time.
0 commit comments