public void Compress() { if (IsPumpActive) { return; } if (!IsCompressed) { Console.WriteLine("Pump compression initiated"); CompressionStartedEvent?.Invoke(this, EventArgs.Empty); IsPumpActive = true; Task.Factory.StartNew(() => { while (!IsCompressed) { _stocking.Pressure += 1; Thread.Sleep(1); } Console.WriteLine("Pump compression complete"); IsPumpActive = false; CompressionFinishedEvent?.Invoke(this, EventArgs.Empty); }); } else { Console.WriteLine("Cannot compress the stocking any further."); } }
public void Compress() { if (IsLaceCtrlActive) { return; } if (!IsCompressed) { Console.WriteLine("Lace compression initiated"); CompressionStartedEvent?.Invoke(this, EventArgs.Empty); IsLaceCtrlActive = true; Task.Factory.StartNew(() => { for (int i = 0; i < ClicksToTighten; i++) { Console.WriteLine("Click " + (i + 1)); Thread.Sleep(100); } IsLaceCtrlActive = false; IsCompressed = true; Console.WriteLine("Lace compression complete"); CompressionFinishedEvent?.Invoke(this, EventArgs.Empty); }); } else { Console.WriteLine("Cannot compress the stocking any further."); } }