How to use ExceptionProvider class of Microsoft.Coyote.Runtime package

Best Coyote code snippet using Microsoft.Coyote.Runtime.ExceptionProvider

Parallel.cs

Source:Parallel.cs Github

copy

Full Screen

...36 /// </summary>37 [MethodImpl(MethodImplOptions.AggressiveInlining)]38 public static void Invoke(params Action[] actions)39 {40 ExceptionProvider.ThrowNotSupportedInvocationException(nameof(SystemTasks.Parallel.Invoke));41 SystemTasks.Parallel.Invoke(actions);42 }43 /// <summary>44 /// Executes each of the provided actions, possibly in parallel, unless the operation is cancelled by the user.45 /// </summary>46 [MethodImpl(MethodImplOptions.AggressiveInlining)]47 public static void Invoke(ParallelOptions parallelOptions, params Action[] actions)48 {49 ExceptionProvider.ThrowNotSupportedInvocationException(nameof(SystemTasks.Parallel.Invoke));50 SystemTasks.Parallel.Invoke(parallelOptions, actions);51 }52 /// <summary>53 /// Executes a for loop in which iterations may run in parallel.54 /// </summary>55 [MethodImpl(MethodImplOptions.AggressiveInlining)]56 public static ParallelLoopResult For(int fromInclusive, int toExclusive, Action<int> body)57 {58 if (CoyoteRuntime.IsExecutionControlled)59 {60 return For(fromInclusive, toExclusive, new ParallelOptions()61 {62 MaxDegreeOfParallelism = MaxDegreeOfParallelism63 }, body);64 }65 return SystemTasks.Parallel.For(fromInclusive, toExclusive, body);66 }67 /// <summary>68 /// Executes a for loop in which iterations may run in parallel and loop options69 /// can be configured.70 /// </summary>71 [MethodImpl(MethodImplOptions.AggressiveInlining)]72 public static ParallelLoopResult For(int fromInclusive, int toExclusive, ParallelOptions parallelOptions, Action<int> body)73 {74 if (CoyoteRuntime.IsExecutionControlled)75 {76 ValidateParallelOptions(parallelOptions);77 var runtime = CoyoteRuntime.Current;78 int numIterations = toExclusive - fromInclusive;79 int numTasks = Math.Min(numIterations, parallelOptions.MaxDegreeOfParallelism);80 var groups = Enumerable.Range(fromInclusive, numIterations)81 .Select((item, index) => new { index, item })82 .GroupBy(x => x.index % numTasks)83 .Select(x => x.Select(y => y.item));84 int index = 0;85 Task[] tasks = new Task[numTasks];86 var options = OperationContext.CreateOperationExecutionOptions();87 foreach (var group in groups)88 {89 tasks[index] = runtime.ScheduleAction(() =>90 {91 foreach (var iteration in group)92 {93 body(iteration);94 }95 }, null, options, false, parallelOptions.CancellationToken);96 index++;97 }98 runtime.WaitAllTasksComplete(tasks);99 return CompletedResult;100 }101 return SystemTasks.Parallel.For(fromInclusive, toExclusive, parallelOptions, body);102 }103 /// <summary>104 /// Executes a for loop in which iterations may run in parallel and the state of105 /// the loop can be monitored and manipulated.106 /// </summary>107 [MethodImpl(MethodImplOptions.AggressiveInlining)]108 public static ParallelLoopResult For(int fromInclusive, int toExclusive, Action<int, ParallelLoopState> body)109 {110 ExceptionProvider.ThrowNotSupportedInvocationException(nameof(SystemTasks.Parallel.For));111 return SystemTasks.Parallel.For(fromInclusive, toExclusive, body);112 }113 /// <summary>114 /// Executes a for loop in which iterations may run in parallel, loop options can115 /// be configured, and the state of the loop can be monitored and manipulated.116 /// </summary>117 [MethodImpl(MethodImplOptions.AggressiveInlining)]118 public static ParallelLoopResult For(int fromInclusive, int toExclusive, ParallelOptions parallelOptions,119 Action<int, ParallelLoopState> body)120 {121 ExceptionProvider.ThrowNotSupportedInvocationException(nameof(SystemTasks.Parallel.For));122 return SystemTasks.Parallel.For(fromInclusive, toExclusive, parallelOptions, body);123 }124 /// <summary>125 /// Executes a for loop with 64-bit indexes in which iterations may run in parallel.126 /// </summary>127 [MethodImpl(MethodImplOptions.AggressiveInlining)]128 public static ParallelLoopResult For(long fromInclusive, long toExclusive, Action<long> body)129 {130 ExceptionProvider.ThrowNotSupportedInvocationException(nameof(SystemTasks.Parallel.For));131 return SystemTasks.Parallel.For(fromInclusive, toExclusive, body);132 }133 /// <summary>134 /// Executes a for loop with 64-bit indexes in which iterations may run in parallel135 /// and loop options can be configured.136 /// </summary>137 [MethodImpl(MethodImplOptions.AggressiveInlining)]138 public static ParallelLoopResult For(long fromInclusive, long toExclusive, ParallelOptions parallelOptions, Action<long> body)139 {140 ExceptionProvider.ThrowNotSupportedInvocationException(nameof(SystemTasks.Parallel.For));141 return SystemTasks.Parallel.For(fromInclusive, toExclusive, parallelOptions, body);142 }143 /// <summary>144 /// Executes a for loop with 64-bit indexes in which iterations may run in parallel145 /// and the state of the loop can be monitored and manipulated.146 /// </summary>147 [MethodImpl(MethodImplOptions.AggressiveInlining)]148 public static ParallelLoopResult For(long fromInclusive, long toExclusive, Action<long, ParallelLoopState> body)149 {150 ExceptionProvider.ThrowNotSupportedInvocationException(nameof(SystemTasks.Parallel.For));151 return SystemTasks.Parallel.For(fromInclusive, toExclusive, body);152 }153 /// <summary>154 /// Executes a for loop with 64-bit indexes in which iterations may run in parallel, loop155 /// options can be configured, and the state of the loop can be monitored and manipulated.156 /// </summary>157 [MethodImpl(MethodImplOptions.AggressiveInlining)]158 public static ParallelLoopResult For(long fromInclusive, long toExclusive, ParallelOptions parallelOptions,159 Action<long, ParallelLoopState> body)160 {161 ExceptionProvider.ThrowNotSupportedInvocationException(nameof(SystemTasks.Parallel.For));162 return SystemTasks.Parallel.For(fromInclusive, toExclusive, parallelOptions, body);163 }164 /// <summary>165 /// Executes a for loop with thread-local data in which iterations may run in parallel,166 /// and the state of the loop can be monitored and manipulated.167 /// </summary>168 [MethodImpl(MethodImplOptions.AggressiveInlining)]169 public static ParallelLoopResult For<TLocal>(int fromInclusive, int toExclusive, Func<TLocal> localInit, Func<int, ParallelLoopState, TLocal, TLocal> body, Action<TLocal> localFinally)170 {171 if (CoyoteRuntime.IsExecutionControlled)172 {173 }174 return SystemTasks.Parallel.For(fromInclusive, toExclusive, localInit, body, localFinally);175 }176 /// <summary>177 /// Executes a for loop with thread-local data in which iterations may run in parallel, loop178 /// options can be configured, and the state of the loop can be monitored and manipulated.179 /// </summary>180 [MethodImpl(MethodImplOptions.AggressiveInlining)]181 public static ParallelLoopResult For<TLocal>(int fromInclusive, int toExclusive, ParallelOptions parallelOptions, Func<TLocal> localInit, Func<int, ParallelLoopState, TLocal, TLocal> body, Action<TLocal> localFinally)182 {183 if (CoyoteRuntime.IsExecutionControlled)184 {185 }186 return SystemTasks.Parallel.For(fromInclusive, toExclusive, parallelOptions, localInit, body, localFinally);187 }188 /// <summary>189 /// Executes a for loop with 64-bit indexes and thread-local data in which iterations190 /// may run in parallel, and the state of the loop can be monitored and manipulated.191 /// </summary>192 [MethodImpl(MethodImplOptions.AggressiveInlining)]193 public static ParallelLoopResult For<TLocal>(long fromInclusive, long toExclusive, Func<TLocal> localInit,194 Func<long, ParallelLoopState, TLocal, TLocal> body, Action<TLocal> localFinally)195 {196 ExceptionProvider.ThrowNotSupportedInvocationException(nameof(SystemTasks.Parallel.For));197 return SystemTasks.Parallel.For(fromInclusive, toExclusive, localInit, body, localFinally);198 }199 /// <summary>200 /// Executes a for loop with 64-bit indexes and thread-local data in which iterations201 /// may run in parallel, loop options can be configured, and the state of the loop202 /// can be monitored and manipulated.203 /// </summary>204 [MethodImpl(MethodImplOptions.AggressiveInlining)]205 public static ParallelLoopResult For<TLocal>(long fromInclusive, long toExclusive, ParallelOptions parallelOptions,206 Func<TLocal> localInit, Func<long, ParallelLoopState, TLocal, TLocal> body, Action<TLocal> localFinally)207 {208 ExceptionProvider.ThrowNotSupportedInvocationException(nameof(SystemTasks.Parallel.For));209 return SystemTasks.Parallel.For(fromInclusive, toExclusive, parallelOptions, localInit, body, localFinally);210 }211 /// <summary>212 /// Executes a foreach operation on a <see cref="System.Collections.IEnumerable"/>213 /// in which iterations may run in parallel.214 /// </summary>215 [MethodImpl(MethodImplOptions.AggressiveInlining)]216 public static ParallelLoopResult ForEach<TSource>(IEnumerable<TSource> source, Action<TSource> body)217 {218 if (CoyoteRuntime.IsExecutionControlled)219 {220 return ForEach(source, new ParallelOptions()221 {222 MaxDegreeOfParallelism = MaxDegreeOfParallelism223 }, body);224 }225 return SystemTasks.Parallel.ForEach(source, body);226 }227 /// <summary>228 /// Executes a foreach operation on a <see cref="System.Collections.IEnumerable"/>229 /// in which iterations may run in parallel and loop options can be configured.230 /// </summary>231 [MethodImpl(MethodImplOptions.AggressiveInlining)]232 public static ParallelLoopResult ForEach<TSource>(IEnumerable<TSource> source, ParallelOptions parallelOptions, Action<TSource> body)233 {234 if (CoyoteRuntime.IsExecutionControlled)235 {236 ValidateParallelOptions(parallelOptions);237 var runtime = CoyoteRuntime.Current;238 var sourceList = source.ToList();239 int numIterations = sourceList.Count;240 int numTasks = Math.Min(numIterations, parallelOptions.MaxDegreeOfParallelism);241 var groups = Enumerable.Range(0, numIterations)242 .Select((item, index) => new { index, item })243 .GroupBy(x => x.index % numTasks)244 .Select(x => x.Select(y => y.item));245 int index = 0;246 Task[] tasks = new Task[numTasks];247 var options = OperationContext.CreateOperationExecutionOptions();248 foreach (var group in groups)249 {250 tasks[index] = runtime.ScheduleAction(() =>251 {252 foreach (var iteration in group)253 {254 body(sourceList[iteration]);255 }256 }, null, options, false, parallelOptions.CancellationToken);257 index++;258 }259 runtime.WaitAllTasksComplete(tasks);260 return CompletedResult;261 }262 return SystemTasks.Parallel.ForEach(source, parallelOptions, body);263 }264 /// <summary>265 /// Executes a foreach operation on a <see cref="Partitioner"/> in which iterations may run in parallel.266 /// </summary>267 [MethodImpl(MethodImplOptions.AggressiveInlining)]268 public static ParallelLoopResult ForEach<TSource>(Partitioner<TSource> source, Action<TSource> body)269 {270 ExceptionProvider.ThrowNotSupportedInvocationException(nameof(SystemTasks.Parallel.ForEach));271 return SystemTasks.Parallel.ForEach(source, body);272 }273 /// <summary>274 /// Executes a foreach operation on a <see cref="Partitioner"/> in which iterations may run275 /// in parallel and loop options can be configured.276 /// </summary>277 [MethodImpl(MethodImplOptions.AggressiveInlining)]278 public static ParallelLoopResult ForEach<TSource>(Partitioner<TSource> source, ParallelOptions parallelOptions, Action<TSource> body)279 {280 ExceptionProvider.ThrowNotSupportedInvocationException(nameof(SystemTasks.Parallel.ForEach));281 return SystemTasks.Parallel.ForEach(source, parallelOptions, body);282 }283 /// <summary>284 /// Executes a foreach operation on a <see cref="System.Collections.IEnumerable"/> in which iterations285 /// may run in parallel, and the state of the loop can be monitored and manipulated.286 /// </summary>287 [MethodImpl(MethodImplOptions.AggressiveInlining)]288 public static ParallelLoopResult ForEach<TSource>(IEnumerable<TSource> source, Action<TSource, ParallelLoopState> body)289 {290 ExceptionProvider.ThrowNotSupportedInvocationException(nameof(SystemTasks.Parallel.ForEach));291 return SystemTasks.Parallel.ForEach(source, body);292 }293 /// <summary>294 /// Executes a foreach operation on a <see cref="System.Collections.IEnumerable"/> in which iterations295 /// may run in parallel, loop options can be configured, and the state of the loop can be monitored and296 /// manipulated.297 /// </summary>298 [MethodImpl(MethodImplOptions.AggressiveInlining)]299 public static ParallelLoopResult ForEach<TSource>(IEnumerable<TSource> source, ParallelOptions parallelOptions,300 Action<TSource, ParallelLoopState> body)301 {302 ExceptionProvider.ThrowNotSupportedInvocationException(nameof(SystemTasks.Parallel.ForEach));303 return SystemTasks.Parallel.ForEach(source, parallelOptions, body);304 }305 /// <summary>306 /// Executes a foreach operation on a <see cref="Partitioner"/> in which iterations may run in parallel,307 /// and the state of the loop can be monitored308 /// and manipulated.309 /// </summary>310 [MethodImpl(MethodImplOptions.AggressiveInlining)]311 public static ParallelLoopResult ForEach<TSource>(Partitioner<TSource> source, Action<TSource, ParallelLoopState> body)312 {313 ExceptionProvider.ThrowNotSupportedInvocationException(nameof(SystemTasks.Parallel.ForEach));314 return SystemTasks.Parallel.ForEach(source, body);315 }316 /// <summary>317 /// Executes a foreach operation on a <see cref="Partitioner"/> in which iterations may run in parallel,318 /// loop options can be configured, and the state of the loop can be monitored and manipulated.319 /// </summary>320 [MethodImpl(MethodImplOptions.AggressiveInlining)]321 public static ParallelLoopResult ForEach<TSource>(Partitioner<TSource> source, ParallelOptions parallelOptions,322 Action<TSource, ParallelLoopState> body)323 {324 ExceptionProvider.ThrowNotSupportedInvocationException(nameof(SystemTasks.Parallel.ForEach));325 return SystemTasks.Parallel.ForEach(source, parallelOptions, body);326 }327 /// <summary>328 /// Executes a foreach operation with 64-bit indexes on a <see cref="System.Collections.IEnumerable"/>329 /// in which iterations may run in parallel, and the state of the loop can be monitored and manipulated.330 /// </summary>331 [MethodImpl(MethodImplOptions.AggressiveInlining)]332 public static ParallelLoopResult ForEach<TSource>(IEnumerable<TSource> source, Action<TSource, ParallelLoopState, long> body)333 {334 ExceptionProvider.ThrowNotSupportedInvocationException(nameof(SystemTasks.Parallel.ForEach));335 return SystemTasks.Parallel.ForEach(source, body);336 }337 /// <summary>338 /// Executes a foreach operation with 64-bit indexes on a <see cref="System.Collections.IEnumerable"/>339 /// in which iterations may run in parallel, loop options can be configured, and the state of the loop340 /// can be monitored and manipulated.341 /// </summary>342 [MethodImpl(MethodImplOptions.AggressiveInlining)]343 public static ParallelLoopResult ForEach<TSource>(IEnumerable<TSource> source, ParallelOptions parallelOptions,344 Action<TSource, ParallelLoopState, long> body)345 {346 ExceptionProvider.ThrowNotSupportedInvocationException(nameof(SystemTasks.Parallel.ForEach));347 return SystemTasks.Parallel.ForEach(source, parallelOptions, body);348 }349 /// <summary>350 /// Executes a foreach operation on a <see cref="OrderablePartitioner{TSource}"/> in which iterations351 /// may run in parallel and the state of the loop can be monitored and manipulated.352 /// </summary>353 [MethodImpl(MethodImplOptions.AggressiveInlining)]354 public static ParallelLoopResult ForEach<TSource>(OrderablePartitioner<TSource> source, Action<TSource, ParallelLoopState, long> body)355 {356 ExceptionProvider.ThrowNotSupportedInvocationException(nameof(SystemTasks.Parallel.ForEach));357 return SystemTasks.Parallel.ForEach(source, body);358 }359 /// <summary>360 /// Executes a foreach operation on a <see cref="OrderablePartitioner{TSource}"/>361 /// in which iterations may run in parallel, loop options can be configured, and362 /// the state of the loop can be monitored and manipulated.363 /// </summary>364 [MethodImpl(MethodImplOptions.AggressiveInlining)]365 public static ParallelLoopResult ForEach<TSource>(OrderablePartitioner<TSource> source, ParallelOptions parallelOptions,366 Action<TSource, ParallelLoopState, long> body)367 {368 ExceptionProvider.ThrowNotSupportedInvocationException(nameof(SystemTasks.Parallel.ForEach));369 return SystemTasks.Parallel.ForEach(source, parallelOptions, body);370 }371 /// <summary>372 /// Executes a foreach operation with thread-local data on a <see cref="System.Collections.IEnumerable"/>373 /// in which iterations may run in parallel, and the state of the loop can be monitored and manipulated.374 /// </summary>375 [MethodImpl(MethodImplOptions.AggressiveInlining)]376 public static ParallelLoopResult ForEach<TSource, TLocal>(IEnumerable<TSource> source, Func<TLocal> localInit,377 Func<TSource, ParallelLoopState, TLocal, TLocal> body, Action<TLocal> localFinally)378 {379 ExceptionProvider.ThrowNotSupportedInvocationException(nameof(SystemTasks.Parallel.ForEach));380 return SystemTasks.Parallel.ForEach(source, localInit, body, localFinally);381 }382 /// <summary>383 /// Executes a foreach operation with thread-local data on a <see cref="System.Collections.IEnumerable"/>384 /// in which iterations may run in parallel, loop options can be configured, and the state of the loop385 /// can be monitored and manipulated.386 /// </summary>387 [MethodImpl(MethodImplOptions.AggressiveInlining)]388 public static ParallelLoopResult ForEach<TSource, TLocal>(IEnumerable<TSource> source, ParallelOptions parallelOptions,389 Func<TLocal> localInit, Func<TSource, ParallelLoopState, TLocal, TLocal> body, Action<TLocal> localFinally)390 {391 ExceptionProvider.ThrowNotSupportedInvocationException(nameof(SystemTasks.Parallel.ForEach));392 return SystemTasks.Parallel.ForEach(source, parallelOptions, localInit, body, localFinally);393 }394 /// <summary>395 /// Executes a foreach operation with thread-local data on a <see cref="Partitioner"/> in which iterations may run in396 /// parallel and the state of the loop can be monitored and manipulated.397 /// </summary>398 [MethodImpl(MethodImplOptions.AggressiveInlining)]399 public static ParallelLoopResult ForEach<TSource, TLocal>(Partitioner<TSource> source, Func<TLocal> localInit,400 Func<TSource, ParallelLoopState, TLocal, TLocal> body, Action<TLocal> localFinally)401 {402 ExceptionProvider.ThrowNotSupportedInvocationException(nameof(SystemTasks.Parallel.ForEach));403 return SystemTasks.Parallel.ForEach(source, localInit, body, localFinally);404 }405 /// <summary>406 /// Executes a foreach operation with thread-local data on a <see cref="Partitioner"/> in which iterations may run in407 /// parallel, loop options can be configured, and the state of the loop can be monitored408 /// and manipulated.409 /// </summary>410 [MethodImpl(MethodImplOptions.AggressiveInlining)]411 public static ParallelLoopResult ForEach<TSource, TLocal>(Partitioner<TSource> source, ParallelOptions parallelOptions,412 Func<TLocal> localInit, Func<TSource, ParallelLoopState, TLocal, TLocal> body, Action<TLocal> localFinally)413 {414 ExceptionProvider.ThrowNotSupportedInvocationException(nameof(SystemTasks.Parallel.ForEach));415 return SystemTasks.Parallel.ForEach(source, parallelOptions, localInit, body, localFinally);416 }417 /// <summary>418 /// Executes a foreach operation with thread-local data on a <see cref="System.Collections.IEnumerable"/>419 /// in which iterations may run in parallel and the state of the loop can be monitored and manipulated.420 /// </summary>421 [MethodImpl(MethodImplOptions.AggressiveInlining)]422 public static ParallelLoopResult ForEach<TSource, TLocal>(IEnumerable<TSource> source, Func<TLocal> localInit,423 Func<TSource, ParallelLoopState, long, TLocal, TLocal> body, Action<TLocal> localFinally)424 {425 ExceptionProvider.ThrowNotSupportedInvocationException(nameof(SystemTasks.Parallel.ForEach));426 return SystemTasks.Parallel.ForEach(source, localInit, body, localFinally);427 }428 /// <summary>429 /// Executes a foreach operation with thread-local data and 64-bit indexes on a <see cref="System.Collections.IEnumerable"/>430 /// in which iterations may run in parallel, loop options can be configured, and the state of the loop can be monitored and431 /// manipulated.432 /// </summary>433 [MethodImpl(MethodImplOptions.AggressiveInlining)]434 public static ParallelLoopResult ForEach<TSource, TLocal>(IEnumerable<TSource> source, ParallelOptions parallelOptions,435 Func<TLocal> localInit, Func<TSource, ParallelLoopState, long, TLocal, TLocal> body, Action<TLocal> localFinally)436 {437 ExceptionProvider.ThrowNotSupportedInvocationException(nameof(SystemTasks.Parallel.ForEach));438 return SystemTasks.Parallel.ForEach(source, parallelOptions, localInit, body, localFinally);439 }440 /// <summary>441 /// Executes a foreach operation with thread-local data on a <see cref="OrderablePartitioner{TSource}"/>442 /// in which iterations may run in parallel, loop options can be configured, and the state of the loop443 /// can be monitored and manipulated.444 /// </summary>445 [MethodImpl(MethodImplOptions.AggressiveInlining)]446 public static ParallelLoopResult ForEach<TSource, TLocal>(OrderablePartitioner<TSource> source, Func<TLocal> localInit,447 Func<TSource, ParallelLoopState, long, TLocal, TLocal> body, Action<TLocal> localFinally)448 {449 ExceptionProvider.ThrowNotSupportedInvocationException(nameof(SystemTasks.Parallel.ForEach));450 return SystemTasks.Parallel.ForEach(source, localInit, body, localFinally);451 }452 /// <summary>453 /// Executes a foreach operation with 64-bit indexes and with thread-local data on454 /// a <see cref="OrderablePartitioner{TSource}"/> in which iterations may run in455 /// parallel , loop options can be configured, and the state of the loop can be456 /// monitored and manipulated.457 /// </summary>458 [MethodImpl(MethodImplOptions.AggressiveInlining)]459 public static ParallelLoopResult ForEach<TSource, TLocal>(OrderablePartitioner<TSource> source, ParallelOptions parallelOptions,460 Func<TLocal> localInit, Func<TSource, ParallelLoopState, long, TLocal, TLocal> body, Action<TLocal> localFinally)461 {462 ExceptionProvider.ThrowNotSupportedInvocationException(nameof(SystemTasks.Parallel.ForEach));463 return SystemTasks.Parallel.ForEach(source, parallelOptions, localInit, body, localFinally);464 }465 /// <summary>466 /// Returns a completed <see cref="ParallelLoopResult"/>.467 /// </summary>468 private static ParallelLoopResult GetCompletedResult()469 {470 ParallelLoopResult result = default;471 FieldInfo field = result.GetType().GetFields(BindingFlags.Instance | BindingFlags.NonPublic)472 .First(f => f.Name is "_completed" || f.Name is "m_completed");473 field.SetValueDirect(__makeref(result), true);474 return result;475 }476 /// <summary>...

Full Screen

Full Screen

ThreadPool.cs

Source:ThreadPool.cs Github

copy

Full Screen

...153 /// </summary>154 [MethodImpl(MethodImplOptions.AggressiveInlining)]155 public static bool BindHandle(SafeHandle osHandle)156 {157 ExceptionProvider.ThrowNotSupportedInvocationException(nameof(SystemThreading.ThreadPool.BindHandle));158#if NET5_0159 if (OperatingSystem.IsWindows())160 {161 return SystemThreading.ThreadPool.BindHandle(osHandle);162 }163 else164 {165 throw new NotSupportedException($"Invoking '{nameof(SystemThreading.ThreadPool.BindHandle)}' is only supported on Windows.");166 }167#else168 return SystemThreading.ThreadPool.BindHandle(osHandle);169#endif170 }171 /// <summary>172 /// Registers a delegate to wait for a <see cref="WaitHandle"/>, specifying a <see cref="TimeSpan"/> for173 /// the time-out.174 /// </summary>175 [MethodImpl(MethodImplOptions.AggressiveInlining)]176 public static RegisteredWaitHandle RegisterWaitForSingleObject(WaitHandle waitObject, WaitOrTimerCallback callBack,177 object state, TimeSpan timeout, bool executeOnlyOnce)178 {179 ExceptionProvider.ThrowNotSupportedInvocationException(nameof(SystemThreading.ThreadPool.RegisterWaitForSingleObject));180 return SystemThreading.ThreadPool.RegisterWaitForSingleObject(waitObject, callBack, state, timeout, executeOnlyOnce);181 }182 /// <summary>183 /// Registers a delegate to wait for a <see cref="WaitHandle"/>, specifying a 32-bit signed integer for184 /// the time-out in milliseconds.185 /// </summary>186 [MethodImpl(MethodImplOptions.AggressiveInlining)]187 public static RegisteredWaitHandle RegisterWaitForSingleObject(WaitHandle waitObject, WaitOrTimerCallback callBack,188 object state, int millisecondsTimeOutInterval, bool executeOnlyOnce)189 {190 ExceptionProvider.ThrowNotSupportedInvocationException(nameof(SystemThreading.ThreadPool.RegisterWaitForSingleObject));191 return SystemThreading.ThreadPool.RegisterWaitForSingleObject(waitObject, callBack, state,192 millisecondsTimeOutInterval, executeOnlyOnce);193 }194 /// <summary>195 /// Registers a delegate to wait for a <see cref="WaitHandle"/>, specifying a 64-bit signed integer for196 /// the time-out in milliseconds.197 /// </summary>198 [MethodImpl(MethodImplOptions.AggressiveInlining)]199 public static RegisteredWaitHandle RegisterWaitForSingleObject(WaitHandle waitObject, WaitOrTimerCallback callBack,200 object state, long millisecondsTimeOutInterval, bool executeOnlyOnce)201 {202 ExceptionProvider.ThrowNotSupportedInvocationException(nameof(SystemThreading.ThreadPool.RegisterWaitForSingleObject));203 return SystemThreading.ThreadPool.RegisterWaitForSingleObject(waitObject, callBack, state,204 millisecondsTimeOutInterval, executeOnlyOnce);205 }206 /// <summary>207 /// Registers a delegate to wait for a <see cref="WaitHandle"/>, specifying a 32-bit unsigned integer for208 /// the time-out in milliseconds.209 /// </summary>210 [MethodImpl(MethodImplOptions.AggressiveInlining)]211 public static RegisteredWaitHandle RegisterWaitForSingleObject(WaitHandle waitObject, WaitOrTimerCallback callBack,212 object state, uint millisecondsTimeOutInterval, bool executeOnlyOnce)213 {214 ExceptionProvider.ThrowNotSupportedInvocationException(nameof(SystemThreading.ThreadPool.RegisterWaitForSingleObject));215 return SystemThreading.ThreadPool.RegisterWaitForSingleObject(waitObject, callBack, state,216 millisecondsTimeOutInterval, executeOnlyOnce);217 }218 /// <summary>219 /// Registers a delegate to wait for a <see cref="WaitHandle"/>, specifying a <see cref="TimeSpan"/> for220 /// the time-out. This method does not propagate the calling stack to the worker thread.221 /// </summary>222 [MethodImpl(MethodImplOptions.AggressiveInlining)]223 public static RegisteredWaitHandle UnsafeRegisterWaitForSingleObject(WaitHandle waitObject, WaitOrTimerCallback callBack,224 object state, TimeSpan timeout, bool executeOnlyOnce)225 {226 ExceptionProvider.ThrowNotSupportedInvocationException(nameof(SystemThreading.ThreadPool.UnsafeRegisterWaitForSingleObject));227 return SystemThreading.ThreadPool.UnsafeRegisterWaitForSingleObject(waitObject, callBack, state, timeout, executeOnlyOnce);228 }229 /// <summary>230 /// Registers a delegate to wait for a <see cref="WaitHandle"/>, specifying a 32-bit signed integer for231 /// the time-out in milliseconds. This method does not propagate the calling stack to the worker thread.232 /// </summary>233 [MethodImpl(MethodImplOptions.AggressiveInlining)]234 public static RegisteredWaitHandle UnsafeRegisterWaitForSingleObject(WaitHandle waitObject, WaitOrTimerCallback callBack,235 object state, int millisecondsTimeOutInterval, bool executeOnlyOnce)236 {237 ExceptionProvider.ThrowNotSupportedInvocationException(nameof(SystemThreading.ThreadPool.UnsafeRegisterWaitForSingleObject));238 return SystemThreading.ThreadPool.UnsafeRegisterWaitForSingleObject(waitObject, callBack, state,239 millisecondsTimeOutInterval, executeOnlyOnce);240 }241 /// <summary>242 /// Registers a delegate to wait for a <see cref="WaitHandle"/>, specifying a 64-bit signed integer for243 /// the time-out in milliseconds. This method does not propagate the calling stack to the worker thread.244 /// </summary>245 [MethodImpl(MethodImplOptions.AggressiveInlining)]246 public static RegisteredWaitHandle UnsafeRegisterWaitForSingleObject(WaitHandle waitObject, WaitOrTimerCallback callBack,247 object state, long millisecondsTimeOutInterval, bool executeOnlyOnce)248 {249 ExceptionProvider.ThrowNotSupportedInvocationException(nameof(SystemThreading.ThreadPool.UnsafeRegisterWaitForSingleObject));250 return SystemThreading.ThreadPool.UnsafeRegisterWaitForSingleObject(waitObject, callBack, state,251 millisecondsTimeOutInterval, executeOnlyOnce);252 }253 /// <summary>254 /// Registers a delegate to wait for a <see cref="WaitHandle"/>, specifying a 32-bit unsigned integer for255 /// the time-out in milliseconds. This method does not propagate the calling stack to the worker thread.256 /// </summary>257 [MethodImpl(MethodImplOptions.AggressiveInlining)]258 public static RegisteredWaitHandle UnsafeRegisterWaitForSingleObject(WaitHandle waitObject, WaitOrTimerCallback callBack,259 object state, uint millisecondsTimeOutInterval, bool executeOnlyOnce)260 {261 ExceptionProvider.ThrowNotSupportedInvocationException(nameof(SystemThreading.ThreadPool.UnsafeRegisterWaitForSingleObject));262 return SystemThreading.ThreadPool.UnsafeRegisterWaitForSingleObject(waitObject, callBack, state,263 millisecondsTimeOutInterval, executeOnlyOnce);264 }265 }266}...

Full Screen

Full Screen

ExceptionProvider.cs

Source:ExceptionProvider.cs Github

copy

Full Screen

...10 /// Provides a set of static methods for working with specific kinds of <see cref="Exception"/> instances.11 /// </summary>12 /// <remarks>This type is intended for compiler use rather than use directly in code.</remarks>13 [EditorBrowsable(EditorBrowsableState.Never)]14 public static class ExceptionProvider15 {16 /// <summary>17 /// Checks if the exception object contains an <see cref="ExecutionCanceledException"/>18 /// and, if yes, it re-throws it so that the exception is not silently consumed.19 /// </summary>20 /// <param name="exception">The exception object.</param>21 public static void ThrowIfExecutionCanceledException(object exception)22 {23 if (exception is ExecutionCanceledException ece)24 {25 throw ece;26 }27 if (exception is Exception ex)28 {...

Full Screen

Full Screen

ExceptionProvider

Using AI Code Generation

copy

Full Screen

1using Microsoft.Coyote.Runtime;2using System;3using System.Collections.Generic;4using System.Linq;5using System.Text;6using System.Threading.Tasks;7{8 {9 static void Main(string[] args)10 {11 {12 throw new Exception("Exception");13 }14 catch (Exception ex)15 {16 ExceptionProvider.Log(ex);17 }18 }19 }20}21using Microsoft.Coyote.Runtime;22using System;23using System.Collections.Generic;24using System.Linq;25using System.Text;26using System.Threading.Tasks;27{28 {29 static void Main(string[] args)30 {31 {32 throw new Exception("Exception");33 }34 catch (Exception ex)35 {36 ExceptionProvider.Log(ex);37 }38 }39 }40}41using Microsoft.Coyote.Runtime;42using System;43using System.Collections.Generic;44using System.Linq;45using System.Text;46using System.Threading.Tasks;47{48 {49 static void Main(string[] args)50 {51 {52 throw new Exception("Exception");53 }54 catch (Exception ex)55 {56 ExceptionProvider.Log(ex);57 }58 }59 }60}61using Microsoft.Coyote.Runtime;62using System;63using System.Collections.Generic;64using System.Linq;65using System.Text;66using System.Threading.Tasks;67{68 {69 static void Main(string[] args)70 {71 {72 throw new Exception("Exception");73 }74 catch (Exception ex)75 {76 ExceptionProvider.Log(ex);77 }78 }79 }80}

Full Screen

Full Screen

ExceptionProvider

Using AI Code Generation

copy

Full Screen

1using Microsoft.Coyote.Runtime;2using System;3using System.Collections.Generic;4using System.Linq;5using System.Text;6using System.Threading.Tasks;7{8 {9 static void Main(string[] args)10 {11 {12 var x = 0;13 var y = 1 / x;14 }15 catch (Exception e)16 {17 ExceptionProvider.Throw(e);18 }19 }20 }21}22using Microsoft.Coyote.Runtime;23using System;24using System.Collections.Generic;25using System.Linq;26using System.Text;27using System.Threading.Tasks;28{29 {30 static void Main(string[] args)31 {32 {33 var x = 0;34 var y = 1 / x;35 }36 catch (Exception e)37 {38 ExceptionProvider.Throw(e);39 }40 }41 }42}43using Microsoft.Coyote.Runtime;44using System;45using System.Collections.Generic;46using System.Linq;47using System.Text;48using System.Threading.Tasks;49{50 {51 static void Main(string[] args)52 {53 {54 var x = 0;55 var y = 1 / x;56 }57 catch (Exception e)58 {59 ExceptionProvider.Throw(e);60 }61 }62 }63}64using Microsoft.Coyote.Runtime;65using System;66using System.Collections.Generic;67using System.Linq;68using System.Text;69using System.Threading.Tasks;70{71 {72 static void Main(string[] args)73 {74 {75 var x = 0;76 var y = 1 / x;77 }78 catch (Exception e)79 {80 ExceptionProvider.Throw(e);81 }82 }83 }84}85using Microsoft.Coyote.Runtime;86using System;87using System.Collections.Generic;88using System.Linq;89using System.Text;90using System.Threading.Tasks;91{

Full Screen

Full Screen

ExceptionProvider

Using AI Code Generation

copy

Full Screen

1using System;2using System.Threading.Tasks;3using Microsoft.Coyote;4using Microsoft.Coyote.Actors;5using Microsoft.Coyote.Runtime;6using Microsoft.Coyote.Specifications;7using Microsoft.Coyote.Tasks;8{9 {10 public static void Main(string[] args)11 {12 {13 RunAsync().Wait();14 }15 catch (Exception ex)16 {17 Console.WriteLine(ex.Message);18 }19 }20 private static async Task RunAsync()21 {22 using (var runtime = RuntimeFactory.Create())23 {24 await runtime.CreateActorAndExecuteAsync(typeof(Actor1));25 }26 }27 }28 {29 private Event WaitEvent;30 [OnEventDoAction(typeof(UnitEvent), nameof(Configure))]31 private class Init : State { }32 private void Configure()33 {34 var provider = new ExceptionProvider();35 provider.SetExceptionToThrowOnEvent(typeof(UnitEvent), new Exception("Test"));36 this.SetExceptionProvider(provider);37 this.SendEvent(this.Id, UnitEvent.Instance);38 }39 [OnEventDoAction(typeof(UnitEvent), nameof(Handle))]40 private class Configured : State { }41 private void Handle()42 {43 this.RaiseFailureEvent();44 }45 }46}47using System;48using System.Threading.Tasks;49using Microsoft.Coyote;50using Microsoft.Coyote.Actors;51using Microsoft.Coyote.Runtime;52using Microsoft.Coyote.Specifications;53using Microsoft.Coyote.Tasks;54{55 {56 public static void Main(string[] args)57 {58 {59 RunAsync().Wait();60 }61 catch (Exception ex)62 {63 Console.WriteLine(ex.Message);64 }65 }66 private static async Task RunAsync()67 {

Full Screen

Full Screen

ExceptionProvider

Using AI Code Generation

copy

Full Screen

1using Microsoft.Coyote.Runtime;2using System;3using System.Threading.Tasks;4{5 {6 static async Task Main(string[] args)7 {8 {9 await Task.Delay(1000);10 throw new Exception("Test exception");11 }12 catch (Exception ex)13 {14 Console.WriteLine("Exception caught");15 ExceptionProvider.Throw(ex);16 }17 }18 }19}20using Microsoft.Coyote.Runtime;21using System;22using System.Threading.Tasks;23{24 {25 static async Task Main(string[] args)26 {27 {28 await Task.Delay(1000);29 throw new Exception("Test exception");30 }31 catch (Exception ex)32 {33 Console.WriteLine("Exception caught");34 ExceptionProvider.Throw(ex);35 }36 }37 }38}39using Microsoft.Coyote.Runtime;40using System;41using System.Threading.Tasks;42{43 {44 static async Task Main(string[] args)45 {46 {47 await Task.Delay(1000);48 throw new Exception("Test exception");49 }50 catch (Exception ex)51 {52 Console.WriteLine("Exception caught");53 ExceptionProvider.Throw(ex);54 }55 }56 }57}58using Microsoft.Coyote.Runtime;59using System;60using System.Threading.Tasks;61{62 {63 static async Task Main(string[] args)64 {65 {66 await Task.Delay(1000);67 throw new Exception("Test exception");68 }69 catch (Exception ex)70 {71 Console.WriteLine("Exception caught");72 ExceptionProvider.Throw(ex);73 }74 }75 }76}77using Microsoft.Coyote.Runtime;78using System;79using System.Threading.Tasks;80{81 {82 static async Task Main(string[] args)83 {84 {85 await Task.Delay(1000);86 throw new Exception("Test exception");

Full Screen

Full Screen

ExceptionProvider

Using AI Code Generation

copy

Full Screen

1using Microsoft.Coyote.Runtime;2using System;3{4 {5 static void Main(string[] args)6 {7 Console.WriteLine("Hello World!");8 ExceptionProvider.Throw(new Exception("Test"));9 }10 }11}12using Microsoft.Coyote.Tasks;13using System;14{15 {16 static void Main(string[] args)17 {18 Console.WriteLine("Hello World!");19 ExceptionProvider.Throw(new Exception("Test"));20 }21 }22}

Full Screen

Full Screen

ExceptionProvider

Using AI Code Generation

copy

Full Screen

1using Microsoft.Coyote.Runtime;2using System;3{4 {5 static void Main(string[] args)6 {7 ExceptionProvider ep = new ExceptionProvider();8 ep.ThrowException(new Exception("This is an exception"));9 }10 }11}12using Microsoft.Coyote.Runtime;13using System;14using Microsoft.Coyote;15{16 {17 static void Main(string[] args)18 {19 ExceptionProvider ep = new ExceptionProvider();20 ep.ThrowException(new Exception("This is an exception"));21 }22 }23}24using Microsoft.Coyote.Runtime;25using System;26using Microsoft.Coyote;27{28 {29 static void Main(string[] args)30 {31 ExceptionProvider ep = new ExceptionProvider();32 ep.ThrowException(new Exception("This is an exception"));33 }34 }35}36using Microsoft.Coyote.Runtime;37using System;38using Microsoft.Coyote;39{40 {41 static void Main(string[] args)42 {43 ExceptionProvider ep = new ExceptionProvider();44 ep.ThrowException(new Exception("This is an exception"));45 }46 }47}48using Microsoft.Coyote.Runtime;49using System;50using Microsoft.Coyote;51{52 {53 static void Main(string[] args)54 {55 ExceptionProvider ep = new ExceptionProvider();56 ep.ThrowException(new Exception("This is an exception"));57 }58 }59}

Full Screen

Full Screen

ExceptionProvider

Using AI Code Generation

copy

Full Screen

1using System;2using System.Threading.Tasks;3using Microsoft.Coyote.Runtime;4{5 {6 static void Main(string[] args)7 {8 ExceptionProvider provider = new ExceptionProvider();9 provider.OnException += (sender, e) =>10 {11 Console.WriteLine("Exception: {0}", e.Exception.Message);12 };13 provider.OnUnhandledException += (sender, e) =>14 {15 Console.WriteLine("Unhandled exception: {0}", e.Exception.Message);16 };17 provider.OnTaskException += (sender, e) =>18 {19 Console.WriteLine("Task exception: {0}", e.Exception.Message);20 };21 provider.OnTaskCanceled += (sender, e) =>22 {23 Console.WriteLine("Task canceled");24 };25 provider.OnTaskFaulted += (sender, e) =>26 {27 Console.WriteLine("Task faulted");28 };29 provider.OnTaskCompleted += (sender, e) =>30 {31 Console.WriteLine("Task completed");32 };33 provider.OnTaskScheduled += (sender, e) =>34 {35 Console.WriteLine("Task scheduled");36 };37 provider.OnTaskStarted += (sender, e) =>38 {39 Console.WriteLine("Task started");40 };41 provider.OnTaskWait += (sender, e) =>42 {43 Console.WriteLine("Task wait");44 };45 provider.OnTaskWaitEnd += (sender, e) =>46 {47 Console.WriteLine("Task wait end");48 };49 provider.OnTaskContinuationScheduled += (sender, e) =>50 {51 Console.WriteLine("Task continuation scheduled");52 };53 provider.OnTaskContinuationStarted += (sender, e) =>54 {55 Console.WriteLine("Task continuation started");56 };57 provider.OnTaskContinuationCompleted += (sender, e) =>58 {59 Console.WriteLine("Task continuation completed");60 };61 provider.OnTaskContinuationFaulted += (sender, e) =>62 {63 Console.WriteLine("Task continuation faulted");64 };65 provider.OnTaskContinuationCanceled += (sender, e) =>66 {67 Console.WriteLine("Task continuation canceled");68 };69 provider.OnTaskContinuationException += (sender, e) =>70 {71 Console.WriteLine("Task continuation exception");72 };73 provider.OnTaskWaitContinuationScheduled += (sender, e) =>74 {75 Console.WriteLine("Task wait continuation scheduled");76 };77 provider.OnTaskWaitContinuationStarted += (sender, e

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Coyote automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful