static public Task LoadAsync(ThreadProperties tp = null) { if (_Loader != null) return _Loader; _Loader = Task.Factory.StartNew( () => { using (tp.GetChanger()) { PythonEvaluator = new PythonEvaluator(); } }, CancellationToken.None, TaskCreationOptions.LongRunning, TaskScheduler.Default); return _Loader; }
public void FromCurrentThread_Test() { ThreadPriority or = Thread.CurrentThread.Priority; if (or == ThreadPriority.Highest) { Thread.CurrentThread.Priority = ThreadPriority.Normal; } Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.Normal; ThreadProperties target = ThreadProperties.FromCurrentThread(); target.Should().NotBeNull(); or = Thread.CurrentThread.Priority; or.Should().NotBe(ThreadPriority.Highest); ProcessPriorityClass orproc = Process.GetCurrentProcess().PriorityClass; orproc.Should().NotBe(ProcessPriorityClass.High); target.ProcessPriorityClass.Should().Be(orproc); target.ThreadPriority.Should().Be(or); ThreadProperties targetprop = new ThreadProperties(ThreadPriority.Highest, null); using (targetprop.GetChanger()) { Thread.CurrentThread.Priority.Should().Be(ThreadPriority.Highest); Process.GetCurrentProcess().PriorityClass.Should().Be(orproc); } Thread.CurrentThread.Priority.Should().Be(or); Process.GetCurrentProcess().PriorityClass.Should().Be(orproc); }
private Task UniversalLoadAsync(IImportExportProgress iIImportProgress, CancellationToken? iCancelationToken, ThreadProperties tp) { return Task.Factory.StartNew( () => { using (tp.GetChanger()) { SecureImport(iIImportProgress, iCancelationToken); } }, CancellationToken.None, TaskCreationOptions.LongRunning, TaskScheduler.Default); }