static void RunSync() { ITestService client = null; var successful = 0; var failed = 0; // initially add 100 entities for (var i = 0; i < _numberOfTasks; i++) { try { if (client == null) { client = ServiceLocator.Current.GetInstance <ITestService>("client"); } client.AddNewEntity(); successful++; } catch (Exception x) { Debug.WriteLine(x.DumpString()); client.Dispose(); client = null; failed++; } } for (var i = 0; i < _numberOfTasks; i++) { try { if (client == null) { client = ServiceLocator.Current.GetInstance <ITestService>("client"); } client.UpdateEntities(); successful++; } catch (Exception x) { Debug.WriteLine(x.DumpString()); client.Dispose(); client = null; failed++; } } if (client == null) { client = ServiceLocator.Current.GetInstance <ITestService>("client"); } var counts = client.GetCounts(); Debug.WriteLine($"Successfully made {successful}/{_numberOfTasks*2} synchronous calls. {failed}/{_numberOfTasks*2} calls failed."); Console.WriteLine($"Successfully made {successful}/{_numberOfTasks*2} synchronous calls. {failed}/{_numberOfTasks*2} calls failed."); Console.WriteLine($"The service created {counts.Entities} entities and {counts.Values} values."); Console.WriteLine($"There are {client.CountOfEntities()} entities and {client.CountOfValues()} values in the database."); }