static ComputePlatform() { lock (typeof(ComputePlatform)) { try { if (platforms != null) { return; } IntPtr[] handles; int handlesLength; CL10.GetPlatformIDs(0, null, out handlesLength); handles = new IntPtr[handlesLength]; CL10.GetPlatformIDs(handlesLength, handles, out handlesLength); List <ComputePlatform> platformList = new List <ComputePlatform>(handlesLength); foreach (IntPtr handle in handles) { platformList.Add(new ComputePlatform(handle)); } platforms = platformList.AsReadOnly(); } catch (DllNotFoundException) { platforms = new List <ComputePlatform>().AsReadOnly(); } } }