protected override void Execute(NativeActivityContext context) { var kernel = Kernel.Get(context); if (kernel != null) { _kernel = new Application(kernel); } else { var kernelPath = KernelPath.Get(context) ?? string.Empty; var kernelArgs = KernelArgs.Get(context) ?? new string[0]; var startupSleep = StartupSleep.Get(context); var enableObjectReferences = EnableObjectReferences.Get(context); var closeOnFinish = CloseKernelOnFinish.Get(context); _kernel = new Application(kernelPath, kernelArgs, enableObjectReferences, closeOnFinish); Task.Run(() => _kernel.Initialization); if (Body == null) { return; } while (!_kernel.Ready) { Console.WriteLine(Resources.WolframLanguageScope_Execute_Waiting_for_client_to_be_ready___); Thread.Sleep(startupSleep); } } Kernel.Set(context, _kernel.KernelLink); context.Properties.Add(@"Application", _kernel); context.ScheduleAction(Body, _kernel, OnCompleted, OnFaulted); }
protected override void Execute(NativeActivityContext context) { var kernelPath = KernelPath.Get(context); var kernelArgs = KernelArgs.Get(context); var startupSleep = StartupSleep.Get(context); var enableObjectReferences = EnableObjectReferences.Get(context); var application = new Application(kernelPath, kernelArgs, enableObjectReferences, false); Task.Run(() => application.Initialization); while (!application.Ready) { Console.WriteLine(Resources.WolframLanguageScope_Execute_Waiting_for_client_to_be_ready___); Thread.Sleep(startupSleep); } Kernel.Set(context, application.KernelLink); }