Concurrent HashSet in .NET Framework?

Your implementation is correct. The .NET Framework does not provide a built-in concurrent hashset type, unfortunately. However, there are some workarounds. ConcurrentDictionary (recommended) This first one is to use the class ConcurrentDictionary<TKey, TValue> in the namespace System.Collections.Concurrent. In the case, the value is pointless, so we can use a simple byte (1 byte in memory). … Read more

Reader/Writer Locks in C++

Since C++ 17 (VS2015) you can use the standard: #include <shared_mutex> typedef std::shared_mutex Lock; typedef std::unique_lock< Lock > WriteLock; typedef std::shared_lock< Lock > ReadLock; Lock myLock; void ReadFunction() { ReadLock r_lock(myLock); //Do reader stuff } void WriteFunction() { WriteLock w_lock(myLock); //Do writer stuff } For older compiler versions and standards you can use boost to … Read more

Lock the Android device programmatically

The activity class should be inner class and the outter class should extend DeviceAdminReceiver public class adminActivity extends DeviceAdminReceiver { public static class Controller extends Activity { DevicePolicyManager mDPM; ComponentName mDeviceAdminSample; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mDPM = (DevicePolicyManager)getSystemService(Context.DEVICE_POLICY_SERVICE); mDeviceAdminSample = new ComponentName(Controller.this, adminActivity.class); } } } To lock the device write the code … Read more

Lock Unlock events iphone

You can use Darwin notifications, to listen for the events. From my testing on a jailbroken iOS 5.0.1 iPhone 4, I think that one of these events might be what you need: com.apple.springboard.lockstate com.apple.springboard.lockcomplete Note: according to the poster’s comments to a similar question I answered here, this should work on a non-jailbroken phone, too. … Read more