Пример #1
0
 public override void DebugBreak()
 {
     SafeDebugger.Break();
 }
Пример #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MyEngine"/> class.
        /// </summary>
        public MyEngine()
            : base(new Container(), new EngineOptions(),
                   new MonitorManager(), new EnvironmentVars(), new ThreadMonitorManager())
        {
            // ensure that all substitution assemblies are loaded
            foreach (var assemblyName in new string[] {
                "Microsoft.ManagedChess.ThreadingWrappers",
                "Microsoft.ManagedChess.Framework35Wrappers",
                "Microsoft.ManagedChess.Framework4Wrappers",
                "Microsoft.ManagedChess.MiniMPIWrappers",
                "Microsoft.ManagedChess.PFXWrappers",
                "ThreadPool40InternalWrappers"
            })                                         // add more wrapper like the ThreadPoolPatch one if you need
            {
#pragma warning disable 0618
                var a = Assembly.LoadWithPartialName(assemblyName); // returns 'null' when assembly is not found
#pragma warning restore 0618
                if (a != null)
                {
                    foreach (var m in a.GetModules())
                    {
                        System.Runtime.CompilerServices.RuntimeHelpers.RunModuleConstructor(m.ModuleHandle); // makes sure module is 'loaded'
                    }
                }
            }

            if (theOnlyOne != null)
            {
                throw new InvalidOperationException("MyEngine created more than once");
            }
            theOnlyOne = this;

            if (this.Options.Breaks.Contains("s"))
            {
                SafeDebugger.Break();
            }

            AppDomain.CurrentDomain.ProcessExit += new EventHandler(CurrentDomain_ProcessExit);
            this.GetService <ISymbolManager>().AddStackFrameFilter(new StackFrameFilter());

            if (this.Options.Logging)
            {
                Console.WriteLine(".NET version: {0}", typeof(object).Assembly.GetName().Version);
            }

            if (!ControllerEnvironment.IsMonitoringEnabled)
            {
                Console.WriteLine("ExtendedReflection monitor not enabled");
                throw new NotImplementedException("ExtendedReflection monitor not enabled");
            }

            ((IMonitorManager)this.GetService <MonitorManager>()).RegisterThreadMonitor(
                new ThreadMonitorFactory(
                    (ThreadMonitorManager)this.GetService <ThreadMonitorManager>()
                    ));

            if (this.Options.MonitorVolatile || this.Options.MonitorAccesses)
            {
                ((IMonitorManager)this.GetService <MonitorManager>()).RegisterObjectAccessThreadMonitor();
            }
            this.ExecutionMonitor.Initialize();
            var tid = this.ExecutionMonitor.CreateThread();
            _ThreadContext.Start(this.ExecutionMonitor, tid);
            // _ThreadContext.Stop(false);
        }