I'm at a loss. I have a Task factory that is starting a function:
Task.Factory.StartNew(() => ServerGetSecureLog(ServerAndProjectorArchive);
private static void ServerGetSecureLog(string archivePath)
{
var localClientManager = InitializeConnection();
var destinationPath = $"{ServerSecureLogFile}";
var result = ServerGetBasicSecureLogAsync(localClientManager);
var sw = StartStopwatch();
//Wait upto 120s
if (!result.Wait(TimeSpan.FromSeconds(120))) // <<< Exception thrown here.
{
StopStopwatch(sw);
log.Warn($"{MethodBase.GetCurrentMethod().Name} took too long to execute (timeout exceeded).");
}
else
{
StopStopwatch(sw);
Thing is, I'm getting an System.AggregateException
being thrown as shown above. I must be going insane., because to debug this, I put breakpoints on EVERY line of code before that, on that same line the exception is being thrown and even the line that starts the thread and the lambda that is called, yet NONE of them are getting hit. Going up one stack frame and I get to the call of the lambda that I put the breakpoint on.
Variable state:
localClientManager
looks to be uninitialized, so seems that the IP got hijacked somehow.
I wouldn't expect the optimizer would do anything on a DEBUG build and there are no unsafe areas in the code. What could cause such bazar behaviour?
Edit
Could Remote Debugging be an issue? Unfortunately, I can't put a debugger on that system, and can't really run the app from a local machine.