Evaluator fails or hangs if it is first run from ThreadPool. If it is initialized from main thread then it succeed in ThreadPool as well.
Strangely, when single-stepping through code an I get "Exception of type 'System.Threading.ThreadAbortException' was thrown" followed
by "The type initializer for 'Mono.CSharp.InteractiveBase' threw an exception.".
However, without debugging Evaluator simply hangs in ThreadPool.
class Program
{
static void Main(string[] args)
{
// If uncommented then both tests succeed
// test(null);
ThreadPool.QueueUserWorkItem(test);
Console.WriteLine("Press any key to quit...");
Console.ReadKey();
}
private static void test(object state)
{
try
{
Console.WriteLine("Starting evaluation. ThreadPool: {0}", Thread.CurrentThread.IsThreadPoolThread);
int result = (int)CSScript.Evaluator.Evaluate("1 + 2;");
Console.WriteLine("Got result: {0}. ThreadPool: {1}", result, Thread.CurrentThread.IsThreadPoolThread);
}
catch (Exception ex)
{
Console.WriteLine("Exception: {0}. ThreadPool: {1}", ex.Message, Thread.CurrentThread.IsThreadPoolThread);
}
}
}