我尝试在不同的线程中执行我的操作,但我想等到我的 Tread 完成后再打开新线程:
public class Play
{
private string _filePath;
private int _deviceNumber;
public Play(string filePath, int deviceNumber)
{
_filePath = filePath;
_deviceNumber = deviceNumber;
}
public void start()
{
Thread thread = new Thread(send);
thread.IsBackground = true;
thread.Start();
}
private void send()
{
ProcessStartInfo processStartInfo = new ProcessStartInfo(@"D:\SendQueue\SendQueue\bin\Debug\Send.exe");
processStartInfo.Arguments = string.Format("{0} {2}{1}{2}", (_deviceNumber).ToString(), _filePath, "\"");
processStartInfo.WindowStyle = ProcessWindowStyle.Hidden;
processStartInfo.RedirectStandardOutput = true;
processStartInfo.RedirectStandardError = true;
processStartInfo.CreateNoWindow = true;
processStartInfo.UseShellExecute = false;
processStartInfo.ErrorDialog = false;
using (Process process = Process.Start(processStartInfo))
{
process.WaitForExit();
}
}
}
从开始按钮单击我正在播放列表框中的所有文件:
for (int i = 0; i < ListBox.Items.Count && shouldContinue; i++)
{
PlayFile play = new PlayFile ((string)ListBox.Items[i], add);
playCapture.start();
}