@@ -32,7 +32,7 @@ private static int DoDelegateReversePInvokeNonBlittable(bool b)
32
32
public static int BlittablePInvokeToBlittableInteropDelegate ( )
33
33
{
34
34
InteropDelegate del = DoDelegateReversePInvoke ;
35
-
35
+
36
36
DoPInvoke ( ( delegate * unmanaged< int , int > ) Marshal . GetFunctionPointerForDelegate ( del ) , 13 ) ;
37
37
GC . KeepAlive ( del ) ;
38
38
@@ -42,13 +42,23 @@ public static int BlittablePInvokeToBlittableInteropDelegate()
42
42
public static int NonBlittablePInvokeToNonBlittableInteropDelegate ( )
43
43
{
44
44
InteropDelegateNonBlittable del = DoDelegateReversePInvokeNonBlittable ;
45
-
45
+
46
46
DoPInvokeNonBlitable ( ( delegate * unmanaged< int , int > ) Marshal . GetFunctionPointerForDelegate ( del ) , true ) ;
47
47
GC . KeepAlive ( del ) ;
48
48
49
49
return 100 ;
50
50
}
51
51
52
+ public static int BlittablePInvokeToBlittableInteropDelegateOnOtherThread ( )
53
+ {
54
+ InteropDelegate del = DoDelegateReversePInvoke ;
55
+
56
+ DoPInvokeWithCallbackOnOtherThread ( ( delegate * unmanaged< int , int > ) Marshal . GetFunctionPointerForDelegate ( del ) , 13 ) ;
57
+ GC . KeepAlive ( del ) ;
58
+
59
+ return 100 ;
60
+ }
61
+
52
62
[ UnmanagedCallersOnly ]
53
63
private static int DoReversePInvoke ( int i )
54
64
{
@@ -61,6 +71,9 @@ private static int DoReversePInvoke(int i)
61
71
[ DllImport ( "Profiler" , EntryPoint = nameof ( DoPInvoke ) ) ]
62
72
public static extern void DoPInvokeNonBlitable ( delegate * unmanaged< int , int > callback , bool i ) ;
63
73
74
+ [ DllImport ( "Profiler" ) ]
75
+ public static extern void DoPInvokeWithCallbackOnOtherThread ( delegate * unmanaged< int , int > callback , int i ) ;
76
+
64
77
public static int BlittablePInvokeToUnmanagedCallersOnly ( )
65
78
{
66
79
DoPInvoke ( & DoReversePInvoke , 13 ) ;
@@ -75,6 +88,13 @@ public static int NonBlittablePInvokeToUnmanagedCallersOnly()
75
88
return 100 ;
76
89
}
77
90
91
+ public static int BlittablePInvokeToUnmanagedCallersOnlyOnOtherThread ( )
92
+ {
93
+ DoPInvokeWithCallbackOnOtherThread ( & DoReversePInvoke , 13 ) ;
94
+
95
+ return 100 ;
96
+ }
97
+
78
98
public static int Main ( string [ ] args )
79
99
{
80
100
if ( args . Length > 1 && args [ 0 ] . Equals ( "RunTest" , StringComparison . OrdinalIgnoreCase ) )
@@ -89,6 +109,10 @@ public static int Main(string[] args)
89
109
return NonBlittablePInvokeToUnmanagedCallersOnly ( ) ;
90
110
case nameof ( NonBlittablePInvokeToNonBlittableInteropDelegate ) :
91
111
return NonBlittablePInvokeToNonBlittableInteropDelegate ( ) ;
112
+ case nameof ( BlittablePInvokeToUnmanagedCallersOnlyOnOtherThread ) :
113
+ return BlittablePInvokeToUnmanagedCallersOnlyOnOtherThread ( ) ;
114
+ case nameof ( BlittablePInvokeToBlittableInteropDelegateOnOtherThread ) :
115
+ return BlittablePInvokeToBlittableInteropDelegateOnOtherThread ( ) ;
92
116
}
93
117
}
94
118
@@ -104,12 +128,22 @@ public static int Main(string[] args)
104
128
105
129
if ( ! RunProfilerTest ( nameof ( NonBlittablePInvokeToUnmanagedCallersOnly ) , nameof ( DoPInvokeNonBlitable ) , nameof ( DoReversePInvoke ) ) )
106
130
{
107
- return 101 ;
131
+ return 103 ;
108
132
}
109
133
110
134
if ( ! RunProfilerTest ( nameof ( NonBlittablePInvokeToNonBlittableInteropDelegate ) , nameof ( DoPInvokeNonBlitable ) , "Invoke" ) )
111
135
{
112
- return 102 ;
136
+ return 104 ;
137
+ }
138
+
139
+ if ( ! RunProfilerTest ( nameof ( BlittablePInvokeToUnmanagedCallersOnlyOnOtherThread ) , nameof ( DoPInvokeWithCallbackOnOtherThread ) , nameof ( DoReversePInvoke ) ) )
140
+ {
141
+ return 105 ;
142
+ }
143
+
144
+ if ( ! RunProfilerTest ( nameof ( BlittablePInvokeToBlittableInteropDelegateOnOtherThread ) , nameof ( DoPInvokeWithCallbackOnOtherThread ) , "Invoke" ) )
145
+ {
146
+ return 106 ;
113
147
}
114
148
115
149
return 100 ;
0 commit comments