private static int Run(Options options) { Console.WriteLine("before gen"); Assembly.Load("GeneratedCode"); Console.WriteLine("after gen"); WorkerId = options.WorkerId; try { connection = CreateConnection(options); dispatcher = CreateDispatcher(connection); if (connection == null || !connection.IsConnected) { logger.Fatal("Failed to connect to SpatialOS"); return(ErrorExitStatus); } wrappedDispatcher = new DispatcherWrapper(dispatcher); wrappedConnection = new ConnectionWrapper(connection); Logger.DefaultLogger.AttachConnection(wrappedConnection); isConnected = true; env = new Environment(wrappedConnection, wrappedDispatcher); FetchAndProcessOps(env.Connection, dispatcher, tickTimeMillis); logger.Info("Completed prewarming - entering main loop"); Console.WriteLine("run loop"); RunEventLoop(); } finally { if (connection != null) { connection.Dispose(); } if (dispatcher != null) { dispatcher.Dispose(); } } Console.WriteLine("exiting"); return(ErrorExitStatus); }