Skip to content

Commit 7dd4c5d

Browse files
committed
Set 'pUserDefined' again, add comments
1 parent 9a66dfe commit 7dd4c5d

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/WinRT.Runtime/Interop/IContextCallback.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,10 @@ static int InvokeCallback(ComCallData* comCallData)
6060
{
6161
return e.HResult;
6262
}
63-
}
64-
65-
ComCallData comCallData;
66-
comCallData.dwDispid = 0;
67-
comCallData.dwReserved = 0;
63+
}
6864

65+
// Store the state object in the thread static to pass to the callback.
66+
// We don't need a volatile write here, we have a memory barrier below.
6967
CallbackData.PerThreadObject = state;
7068

7169
int hresult;
@@ -81,6 +79,11 @@ static int InvokeCallback(ComCallData* comCallData)
8179
callbackData.Callback = callback;
8280
callbackData.StatePtr = statePtr;
8381

82+
ComCallData comCallData;
83+
comCallData.dwDispid = 0;
84+
comCallData.dwReserved = 0;
85+
comCallData.pUserDefined = (IntPtr)(void*)&callbackData;
86+
8487
Guid iid = IID.IID_ICallbackWithNoReentrancyToApplicationSTA;
8588

8689
// Add a memory barrier to be extra safe that the target thread will be able to see

0 commit comments

Comments
 (0)