public static void SuspendWire()
 {
     if (Running && active)
     {
         runnigBackup   = Wiring.running;
         Wiring.running = false;
         VisualizerWorld.BuildMarkerCache();
         AutoStepWorld.ResetTimer();
         mainWait.Set();
         wiringWait.WaitOne();
     }
 }
        public static bool BeginTripWire(int left, int top, int width, int height)
        {
            if (!Active || Thread.CurrentThread.Name == wireThreadName)
            {
                VisualizerWorld.AddStart(new Rectangle(left, top, width, height));
                return(true);
            }

            if (Running)
            {
                if (queuedWireTrips.Count < maxQueuedTrips)
                {
                    queuedWireTrips.Enqueue(new Rectangle(left, top, width, height));
                }
                return(false);
            }

            VisualizerWorld.ResetSegments();

            Running = true;

            Thread wireThread = new Thread(delegate(object rand)
            {
                Main.rand = (UnifiedRandom)rand; //Main.rand is ThreadStatic, but we need it for faulty gates
                Wiring.TripWire(left, top, width, height);
                Running = false;
                mainWait.Set();
            });

            wireThread.IsBackground = true;
            wireThread.Name         = wireThreadName;
            wireThread.Start(Main.rand);

            mainWait.WaitOne();

            return(false);
        }