public string doResourceAccess() { Console.WriteLine(classNameLog + "Do resource access"); currentlyAccessing = true; //clear permission, do request access //String nowResource; ResourceHandler resourceHandler = new ResourceHandler(); if (wantWrite) { Console.WriteLine(classNameLog + "Write random string to resource"); myString = resourceHandler.generateRandomString(); Console.WriteLine(classNameLog + "Random string generated => " + myString); finalString = resourceHandler.appendNewString(myIp, masterIp, myString); } else { Console.WriteLine(classNameLog + "Read shared string"); finalString = resourceHandler.readNewString(myIp, masterIp); } Console.WriteLine(classNameLog + "Resource value now => " + finalString); haveInterest = false; currentlyAccessing = false; return finalString; }