public void AddCountry(Country country) { lock(_lockObj) { SyncedAccessList.Add(FirstMarker); Thread.Sleep(2000); SyncedAccessList.Add(SecondMarker); } }
public void AddCountry(Country country) { //don't allow multiple threads to access file in the same time lock(_lockObj) { var countries = GetCountries(); countries.CountryList.Add(country); Save(countries); } }
public ActionResult Create(Country model) { _countriesService.AddCountry(model); return RedirectToAction("Index"); }