This repository was archived by the owner on Jan 23, 2023. It is now read-only.
Commit ecf00da
committed
Fix race condition in SystemEvents tests
When attaching a handler from two different threads at once, the first starts creating
the HWND and waits for the event thread to spin up and create the window. The problem
is that it will wait *after* initializing the SystemEvents instance singleton so the second
thread will just skip the initialization and return since it sees the instance is already created.
This is probably not an issue for the API itself since it doesn't make any garuntees about
how soon after you attach to the handler you can receive events, but the tests assume
that they can find the window and send messages to it immediately after attaching to
an event.
Fix this by waiting on the same manualresetevent that the first thread is waiting on.1 parent fc1a878 commit ecf00da
1 file changed
+19
-7
lines changedLines changed: 19 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
20 | 27 | | |
21 | 28 | | |
22 | 29 | | |
23 | | - | |
24 | | - | |
25 | | - | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
26 | 36 | | |
27 | | - | |
28 | | - | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
29 | 40 | | |
30 | 41 | | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
31 | 45 | | |
32 | 46 | | |
33 | 47 | | |
34 | 48 | | |
35 | 49 | | |
36 | 50 | | |
37 | 51 | | |
38 | | - | |
39 | | - | |
40 | 52 | | |
41 | 53 | | |
42 | 54 | | |
0 commit comments