RunSynchronously may not be called on task that was already started

The problem is that you started the task when you call TaskFactory.StartNew – I mean, it’s even in the name of the method that you are starting the task. StartNew creates the task, then calls Start on your behalf. =D

If you want, you can either Wait on the task, like @Peter Ritchie said, or you can create the task manually like so:

var task = new Task(() => { ... });
task.RunSynchronously();

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)