/// <summary> /// Transmits an IR code asynchronously. /// </summary> /// <param name="irCode">The IR code to transmit.</param> /// <param name="codeFormat">The format of the IR code.</param> /// <param name="repeatCount"> /// Indicates how many iterations of the code should be /// sent (in the case of a 2-piece code, the first stream is sent once followed /// by the second stream sent repeatCount times). /// </param> /// <param name="inactivityWaitTime"> /// Time in milliseconds since the last received /// IR activity to wait before sending an IR code. Normally, pass 0 for this parameter. /// </param> /// <param name="userState"> /// An optional user state object that will be passed to the /// TransmitCompleted event. /// </param> public void TransmitAsync( string irCode, CodeFormat codeFormat, int repeatCount, TimeSpan inactivityWaitTime, object userState) { CheckDisposed(); if (null == irCode) { throw new ArgumentNullException("irCode", "irCode cannot be null"); } if (0 == irCode.Length) { throw new ArgumentException("irCode", "irCode cannot be empty"); } if (repeatCount < 0) { throw new ArgumentOutOfRangeException("repeatCount", "repeatCount cannot be negative"); } if (inactivityWaitTime < TimeSpan.Zero) { throw new ArgumentOutOfRangeException("inactivityWaitTime", "inactivityWaitTime cannot be less than TimeSpan.Zero"); } var transmitState = new TransmitState(irCode, codeFormat, repeatCount, Convert.ToInt32(inactivityWaitTime.TotalMilliseconds), userState); if (false == ThreadPool.QueueUserWorkItem(DoTransmit, transmitState)) { throw new ApplicationException("Unable to QueueUserWorkItem"); } }
/// <summary> /// Transmits an IR code asynchronously. /// </summary> /// <param name="irCode">The IR code to transmit.</param> /// <param name="codeFormat">The format of the IR code.</param> /// <param name="repeatCount">Indicates how many iterations of the code should be /// sent (in the case of a 2-piece code, the first stream is sent once followed /// by the second stream sent repeatCount times).</param> /// <param name="inactivityWaitTime">Time in milliseconds since the last received /// IR activity to wait before sending an IR code. Normally, pass 0 for this parameter.</param> /// <param name="userState">An optional user state object that will be passed to the /// TransmitCompleted event.</param> public void TransmitAsync( string irCode, CodeFormat codeFormat, int repeatCount, TimeSpan inactivityWaitTime, object userState) { CheckDisposed(); if (null == irCode) { throw new ArgumentNullException("irCode", "irCode cannot be null"); } if (0 == irCode.Length) { throw new ArgumentException("irCode", "irCode cannot be empty"); } if (repeatCount < 0) { throw new ArgumentOutOfRangeException("repeatCount", "repeatCount cannot be negative"); } if (inactivityWaitTime < TimeSpan.Zero) { throw new ArgumentOutOfRangeException("inactivityWaitTime", "inactivityWaitTime cannot be less than TimeSpan.Zero"); } TransmitState transmitState = new TransmitState(irCode, codeFormat, repeatCount, Convert.ToInt32(inactivityWaitTime.TotalMilliseconds), userState); if (false == ThreadPool.QueueUserWorkItem(new WaitCallback(DoTransmit), transmitState)) { throw new ApplicationException("Unable to QueueUserWorkItem"); } }