/// <summary> /// Scans provided collection of frequencies against specified Squelch value. /// </summary> /// <param name="frequency">a collection of frequency bands which should get scanned</param> /// <param name="threshold">Raw squelch value [0-256]</param> /// <remarks> The block scanning automatically ends when scanned RAW signal strength value rises <see cref="G313BlockScanner.FrequencyScanned"/>the event.</remarks> /// <returns>Returns true if the operation is started</returns> /// <exception cref="InvalidOperationException">Cannot start when scanning is in-progress.</exception> public bool Start(ICollection <uint> frequency, int threshold = 256) { if (_started) { throw new InvalidOperationException("block scanning already in progress"); } _frequencies = frequency.ToArray(); _rawStrength = new uint[_frequencies.Count()]; _frequencies.CopyTo(_rawStrength, 0); _threshold = threshold; _gcHandle = GCHandle.Alloc(_rawStrength, GCHandleType.Pinned); var result = G313Api.BlockScan(_parent.Handle.ToInt32(), _gcHandle.AddrOfPinnedObject(), (uint)_frequencies.Length, threshold, uint.MaxValue, IntPtr.Zero, 0); if (!result) { _gcHandle.Free(); return(false); } _started = true; _task = TaskUtility.Run(MonitorScan); //_task = Task.Run(() => MonitorScan()); return(true); }