C#代码中显示消息框 “2”,但不显示 “1”,用于音频转换。

huangapple go评论64阅读模式
英文:

Message box displaying "2" but not "1" in C# code for audio conversion

问题

我有一个使用FFmpeg进行音频转换的C#代码片段。代码包括两个消息框,一个显示"2",另一个显示"1"。然而,在运行时,只有显示"2"的消息框,而显示"1"的消息框不会显示。以下是代码的相关部分:

MessageBox.Show("2"); // 这个消息框被显示
ffmpegProcess.Start();
ffmpegProcess.WaitForExit();
ffmpegProcess.Close();
MessageBox.Show("1"); // 这个消息框不会被显示

我已经确认显示"1"的消息框的代码没有被注释掉,并且没有报告任何异常或错误。奇怪的是,在显示"1"的消息框所在的代码块之前,显示"2"的消息框正确显示。

我对为什么显示"1"的消息框没有显示而显示"2"的消息框正确显示感到困惑。我已经检查了条件和变量,它们似乎都是正确的。是否有任何可能的原因或陷阱可以阻止显示"1"的消息框?对于排除故障或进一步调查此问题的任何建议都将不胜感激。

提前感谢您的帮助!

英文:

I have a C# code snippet that performs audio conversion using FFmpeg. The code includes two message boxes, one displaying "2" and another displaying "1". However, during runtime, only the message box with "2" is shown, while the one with "1" is not displayed. Here's the relevant part of the code:

MessageBox.Show("2"); // This message box is displayed
ffmpegProcess.Start();
ffmpegProcess.WaitForExit();
ffmpegProcess.Close();
MessageBox.Show("1"); // This message box is not displayed

I've verified that the code for displaying the message box with "1" is not commented out and that there are no exceptions or errors reported. Strangely, the message box displaying "2" appears correctly before the code block where the message box with "1" is located.

I'm puzzled as to why the message box with "1" is not shown while the one with "2" appears correctly. I've checked the conditions and variables, and they seem to be in order. Are there any potential reasons or pitfalls that could prevent the message box with "1" from being displayed? Any suggestions for troubleshooting or further investigating this issue would be greatly appreciated.

Thank you in advance for your assistance!

答案1

得分: 1

有两个阻塞调用,直到第二个MessageBox显示之前。第一个是第一次调用MessageBox.Show,第二个是ffmpegProcess.WaitForExit();。需要检查的事项如下:

  1. 你是否真的关闭了第一个MessageBoxMessageBox.Show()模态,这意味着它会阻塞,直到用户关闭MessageBox
  2. ffmpegProcess是否真的退出了?

假设你关闭了MessageBox,请在MessageBox.Show("1");上设置一个断点,看看是否实际到达了那段代码。看起来你的ffmpeg作业可能只是没有退出。

还有一件事要注意;你等待多久了?你没有说明你对ffmpeg做了什么,但它可能是一个非常长时间运行的操作。也可能是你的ffmpeg作业还没有退出。

英文:

There are two blocking calls before you get to where the second MessageBox would be displayed. The first one is the first call to MessageBox.Show, the second is ffmpegProcess.WaitForExit();. The things to check, then, are:

  1. Are you actually closing the first MessageBox? MessageBox.Show() is modal, which means it blocks until the MessageBox is closed by the user
  2. Is ffmpegProcess actually ever exiting?

Assuming you are closing the MessageBox, place a breakpoint on MessageBox.Show("1"); and see if that code is ever actually reached. Seems likely that your ffmpeg job just isn't exiting.

One other thing to note; how long are you waiting for? You haven't said what you're doing with ffmpeg, but it could be a very long-running operation. It might just be the case that your ffmpeg job hasn't exited yet.

huangapple
  • 本文由 发表于 2023年7月14日 05:14:03
  • 转载请务必保留本文链接:https://go.coder-hub.com/76683277.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定