TaskCompletionSource<bool> sy;
public string SendResponse(HttpListenerRequest request)
{
string result = "";
string key = request.QueryString.GetKey(0);
if (key == "cmd")
{
if (request.QueryString[0] == "upload status")
{
if (Youtube_Uploader.fileuploadstatus == "uploading file")
{
Youtube_Uploader.fileuploadstatus = "";
return "uploading";
}
else
{
return "upload unknown state";
}
if (Youtube_Uploader.fileuploadstatus == "file uploaded successfully")
{
Youtube_Uploader.fileuploadstatus = "";
return "upload completed";
}
else
{
return "upload unknown state";
}
}
if (request.QueryString[0] == "nothing")
{
return "Connection Success";
}
if (request.QueryString[0] == "start")
{
StartRecrod();
result = "Recording started";
}
if (request.QueryString[0] == "stop")
{
dirchanged = false;
StartRecrod();
result = "Recording stopped and preparing the file to be shared on youtube";
sy = new TaskCompletionSource<bool>();
WatchDirectory();
sy.Task.Wait();
Youtube_Uploader youtubeupload = new Youtube_Uploader(fileforupload);
}
}
else
{
result = "Nothing have been done";
}
return result;
}
This line:
if (Youtube_Uploader.fileuploadstatus == "file uploaded successfully")
The 'if' is with green underline and say Unreachable code detected. How can i fix it and why it's Unreachable code ?
Maybe i need to use result = and not return ? But that's not seems to be the problem.