• 0

[.NET] C# Compiler Missing Statements


Question

Hi guys, I have a little problem with my C# code and I need some help. My program essentially runs a series of external executables using threads that run processes. I have no problem running threads and processes but my program will miss out vital code if I don't simply put a MessageBox at that specific point of code.

Check this;

public void callWav()
		{
			if (isVideo == true && isAudio == false) {  sendH264ToMP4(exFileVideo); }

			else if (isAudio == true || isVideoAndAudio == true)
			{
				//code

				if (ac3Exists == true)
				{
					threadCon(new MyAudioMethod(createAudio), "Converting AC3 to WAV", parameter, "\\valdec.exe");
				}

				MessageBox.Show("w");
			}
		}

		public void threadCon(MyAudioMethod methodToRun, string name, string _parameter, string _path)
		{
			threadConversion = new Thread(delegate() { methodToRun(_parameter, _path); });
			threadConversion.Name = name;
			threadConversion.IsBackground = true;
			threadConversion.Start();
		}

		public void createAudio(string _parameter, string _path)
		{
			string path = (executableDirectory + _path);

			runProcess(path, _parameter);
			runExecutable.WaitForExit();
			MessageBox.Show("If I don't put this here the compiler will skip the WaitForForExit(); and run the MessageBox("w")
			processRan = false;
		}

Cheers

Edit: Double Topic Sorry

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

I think I kinda figured it out, since I'm using a Thread other than the main thread, the main thread is going to carry on processing statements. threadConversion is where the WaitForExit() is so that thread is going to wait not the main thread.

Is that correct? if so how do make the main thread wait

cheers

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.