Thread recording;
some method{
if (!state) {
state = true;
recording = new Thread(GetStream(aux)); !!!! error cannot copnvert from void to System.action
recording.Start();
}
else
{
state = false;
}
}
private void GetStream(string aux)
{
string now = DateTime.Now.ToString();
now = now.Replace(':', '-');
fs = new FileStream(now + ".mp3", FileMode.Create);
try
{
response = WebRequest.Create(aux).GetResponse();
}
catch (System.Exception ex)
{
System.Console.WriteLine("Unable to get web response: " + ex);
}
using (System.IO.Stream stream = response.GetResponseStream())
{
byte[] buffer = new byte[65536];
int read;
while ((state == true) && ((read = stream.Read(buffer, 0, buffer.Length)) > 0))
{
long pos = fs.Position;
fs.Position = fs.Length;
fs.Write(buffer, 0, read);
fs.Position = pos;
}
fs.Flush();
}
response.Close();
fs.Close();
}
i dont know how to run this method qith a new thread
Hi, try it like this:
recording = new Thread(() => GetStream(string aux));
recording .Start();
Answers
Hi, try it like this:
recording = new Thread(() => GetStream(string aux));
recording .Start();