Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ ObtainSafeWaitHandles()

static void System.Threading.WaitHandle.ObtainSafeWaitHandles ( ReadOnlySpan< WaitHandle > waitHandles,
Span< SafeWaitHandle > safeWaitHandles,
Span< IntPtr > unsafeWaitHandles )
inlinestaticprivate

Definition at line 173 of file WaitHandle.cs.

174 {
175 bool success = true;
176 SafeWaitHandle safeWaitHandle = null;
177 try
178 {
179 for (int i = 0; i < waitHandles.Length; i++)
180 {
181 WaitHandle waitHandle = waitHandles[i];
182 if (waitHandle == null)
183 {
184 throw new ArgumentNullException("waitHandles[" + i + "]", SR.ArgumentNull_ArrayElement);
185 }
186 SafeWaitHandle safeWaitHandle2 = waitHandle._waitHandle ?? throw new ObjectDisposedException(null, SR.ObjectDisposed_Generic);
187 safeWaitHandle = safeWaitHandle2;
188 success = false;
189 safeWaitHandle2.DangerousAddRef(ref success);
190 safeWaitHandles[i] = safeWaitHandle2;
191 unsafeWaitHandles[i] = safeWaitHandle2.DangerousGetHandle();
192 }
193 }
194 catch
195 {
196 for (int j = 0; j < waitHandles.Length; j++)
197 {
198 SafeWaitHandle safeWaitHandle3 = safeWaitHandles[j];
199 if (safeWaitHandle3 == null)
200 {
201 break;
202 }
203 safeWaitHandle3.DangerousRelease();
204 safeWaitHandles[j] = null;
205 if (safeWaitHandle3 == safeWaitHandle)
206 {
207 safeWaitHandle = null;
208 success = true;
209 }
210 }
211 if (!success)
212 {
213 safeWaitHandle.DangerousRelease();
214 }
215 throw;
216 }
217 }
void DangerousAddRef(ref bool success)
Definition SafeHandle.cs:76

References System.SR.ArgumentNull_ArrayElement, System.Runtime.InteropServices.SafeHandle.DangerousAddRef(), System.Runtime.InteropServices.SafeHandle.DangerousGetHandle(), System.Runtime.InteropServices.SafeHandle.DangerousRelease(), System.ReadOnlySpan< T >.Length, and System.SR.ObjectDisposed_Generic.

Referenced by System.Threading.WaitHandle.WaitMultiple().