I’m sorry if the title is confusing but I’m trying to record audio for 5 seconds and then run the close function.
I figured I just do it like this
StartFunction();
Thread.Sleep(5000);
StopFunction();
But that doesn’t work since it will also not record while the thread is sleeping.
Then I figured maybe if I make a new thread, to do the sleep and stopfunction in. But when I do that and try to run the stopfunction it doesn’t seem to stop anymore because it’s trying to stop the recording in another thread if that makes sense.
So if anyone knows how I could fix this, please let me know
You need to use a
Timer. There are three timers in .NET:System.Threading.Timer,System.Timers.TimerandSystem.Windows.Forms.Timer.Only the latter can assure you it will operate in the same thread. You need a Windows Application for that.