/// <summary> /// Handle a file abort request /// </summary> /// <returns>Asynchronous task</returns> private static async Task HandleAbortFileRequest() { DataTransfer.ReadAbortFile(out CodeChannel channel, out bool abortAll); _logger.Info("Received file abort request on channel {0} for {1}", channel, abortAll ? "all files" : "the last file"); if (abortAll && channel == CodeChannel.File) { using (await Print.LockAsync()) { Print.Abort(); } } _channels[channel].InvalidateBuffer(!abortAll); while (_channels[channel].NestedMacros.TryPop(out MacroFile macroFile)) { macroFile.StartCode?.HandleReply(new CodeResult()); macroFile.Abort(); macroFile.Dispose(); if (!abortAll) { break; } } }
private void End(bool a) { if (InvokeRequired) { SetVisibleCallback d = new SetVisibleCallback(End); Invoke(d, new object[] { a }); } else { print.Abort(); Thread.Sleep(1000); label2.Text = string.Format("???? {0:0.##} ??????. ?????? {1:0.##} ??????.", time, time / 60); state = 5; CheckState(); tabControl1.SelectedIndex = 5; } }
/// <summary> /// Invalidate every resource due to a critical event /// </summary> /// <param name="message">Reason why everything is being invalidated</param> /// <returns>Asynchronous task</returns> private static async Task Invalidate(string message) { bool outputMessage = Print.IsPrinting; // Cancel the file being printed using (await Print.LockAsync()) { Print.Abort(); } // Resolve pending macros, unbuffered (system) codes and flush requests foreach (ChannelInformation channel in _channels) { using (await channel.LockAsync()) { outputMessage |= channel.Invalidate(); } } _bytesReserved = _bufferSpace = 0; // Resolve pending heightmap requests using (await _heightmapLock.LockAsync()) { if (_getHeightmapRequest != null) { _getHeightmapRequest.SetCanceled(); _getHeightmapRequest = null; outputMessage = true; } if (_setHeightmapRequest != null) { _setHeightmapRequest.SetCanceled(); _setHeightmapRequest = null; outputMessage = true; } } // Keep this event in the log... if (!string.IsNullOrWhiteSpace(message)) { if (outputMessage) { await Utility.Logger.LogOutput(MessageType.Warning, message); } else { await Utility.Logger.Log(MessageType.Warning, message); } } }
private static async Task HandleAbortFileRequest() { DataTransfer.ReadAbortFile(out CodeChannel channel, out bool abortAll); Console.WriteLine($"[info] Received file abort request on channel {channel} for {(abortAll ? "all files" : "the last file")}"); if (abortAll && channel == CodeChannel.File) { await Print.Abort(); } _channels[channel].InvalidateBuffer(!abortAll); while (_channels[channel].NestedMacros.TryPop(out MacroFile macroFile)) { macroFile.StartCode?.HandleReply(new CodeResult()); macroFile.Abort(); macroFile.Dispose(); if (!abortAll) { break; } } }
private void Form_print_FormClosing(object sender, FormClosingEventArgs e) { print?.Abort(); }