47
1
using System;
2
using System.Linq;
3
using System.Threading;
4
using System.Threading.Tasks;
5
6
public class Program
7
{
8
public static void Main()
9
{
10
int[] nums = Enumerable.Range(0, 100000).ToArray();
11
CancellationTokenSource cts = new CancellationTokenSource();
12
13
// Use ParallelOptions instance to store the CancellationToken
14
ParallelOptions po = new ParallelOptions();
15
po.CancellationToken = cts.Token;
16
po.MaxDegreeOfParallelism = System.Environment.ProcessorCount;
17
Console.WriteLine($"ProcessorCount: {System.Environment.ProcessorCount}");
18
19
// Run a task so that we can cancel from another thread.
20
Task.Factory.StartNew(async () =>
21
{
22
Console.WriteLine($"Task started {DateTime.Now}");
23
await Task.Delay(10);
24
cts.Cancel();
Cached Result
Unhandled exception. System.TypeInitializationException: The type initializer for 'System.Data.Entity.DbContext' threw an exception.
---> System.TypeInitializationException: The type initializer for 'Z.EntityFramework.Classic.EntityFrameworkManager' threw an exception.
---> System.TypeInitializationException: The type initializer for '' threw an exception.
---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Configuration.ConfigurationManager, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.
File name: 'System.Configuration.ConfigurationManager, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
at Z.Expressions.CompilerManager..cctor()
at Z.Expressions.CompilerManager.LoadEntityFrameworkClassicConfiguration()
at Z.Expressions.ExceptionMessage.ThrowLicenseException()
at ..cctor()
--- End of inner exception stack trace ---
at .()
at Z.EntityFramework.Classic.EntityFrameworkManager..cctor()
--- End of inner exception stack trace ---
at Z.EntityFramework.Classic.EntityFrameworkManager.Initialize()
at System.Data.Entity.DbContext..cctor()
--- End of inner exception stack trace ---
at System.Data.Entity.DbContext..ctor(String nameOrConnectionString)
at Program.EntityContext..ctor()
at Program.GenerateData()
at Program.Main()
Command terminated by signal 6
---> System.TypeInitializationException: The type initializer for 'Z.EntityFramework.Classic.EntityFrameworkManager' threw an exception.
---> System.TypeInitializationException: The type initializer for '' threw an exception.
---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Configuration.ConfigurationManager, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.
File name: 'System.Configuration.ConfigurationManager, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
at Z.Expressions.CompilerManager..cctor()
at Z.Expressions.CompilerManager.LoadEntityFrameworkClassicConfiguration()
at Z.Expressions.ExceptionMessage.ThrowLicenseException()
at ..cctor()
--- End of inner exception stack trace ---
at .()
at Z.EntityFramework.Classic.EntityFrameworkManager..cctor()
--- End of inner exception stack trace ---
at Z.EntityFramework.Classic.EntityFrameworkManager.Initialize()
at System.Data.Entity.DbContext..cctor()
--- End of inner exception stack trace ---
at System.Data.Entity.DbContext..ctor(String nameOrConnectionString)
at Program.EntityContext..ctor()
at Program.GenerateData()
at Program.Main()
Command terminated by signal 6