diff --git a/MatterControlLib/PrinterCommunication/Io/SwitchExtruderStream.cs b/MatterControlLib/PrinterCommunication/Io/SwitchExtruderStream.cs index 42422430c..a09c1f158 100644 --- a/MatterControlLib/PrinterCommunication/Io/SwitchExtruderStream.cs +++ b/MatterControlLib/PrinterCommunication/Io/SwitchExtruderStream.cs @@ -36,7 +36,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io { public class SwitchExtruderStream : GCodeStreamProxy { - private List commandQueue = new List(); + private Queue commandQueue = new Queue(); private object locker = new object(); private int requestedExtruder; private int extruderLastSwitchedTo; @@ -86,16 +86,16 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io string gcodeLine = linesToWrite[i].Trim(); if (gcodeLine.Length > 0) { - commandQueue.Add(gcodeLine); + commandQueue.Enqueue(gcodeLine); } } } else { - commandQueue.Add(gcodeToQueue); + commandQueue.Enqueue(gcodeToQueue); } - commandQueue.Add(lineIn); + commandQueue.Enqueue(lineIn); queuedSwitch = true; } @@ -114,9 +114,8 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io { if (commandQueue.Count > 0) { - lineToSend = commandQueue[0]; + lineToSend = commandQueue.Dequeue(); lineToSend = printer.ReplaceMacroValues(lineToSend); - commandQueue.RemoveAt(0); } }