UsbUirt.Controller.TransmitAsync C# (CSharp) Method

TransmitAsync() public method

Transmits an IR code asynchronously using the default code format.
public TransmitAsync ( string irCode ) : void
irCode string The IR code to transmit.
return void
        public void TransmitAsync(string irCode)
        {
            CheckDisposed();
            TransmitAsync(irCode, _defaultTransmitCodeFormat, _defaultRepeatCount, _defaultInactivityWaitTime, null);
        }

Same methods

Controller::TransmitAsync ( string irCode, CodeFormat codeFormat, int repeatCount, System.TimeSpan inactivityWaitTime ) : void
Controller::TransmitAsync ( string irCode, CodeFormat codeFormat, int repeatCount, System.TimeSpan inactivityWaitTime, object userState ) : void

Usage Example

コード例 #1
0
ファイル: TestApp.cs プロジェクト: sjroesink/zVirtualScenes
        private static bool DoLoop(Controller mc)
        {
            string toDo = String.Empty;
            do
            {
                Console.WriteLine("\nUsbUirt Managed Wrapper Test Menu v0.5:");
                Console.WriteLine("---------------------------------------");
                Console.WriteLine("(1) Transmit IR Code (blocking)");
                Console.WriteLine("(2) Transmit IR Code (non-blocking)");
                Console.WriteLine("(3) Learn IR Code (Pronto Format)");
                Console.WriteLine("(4) Learn IR Code (UIRT-Raw Format)");
                Console.WriteLine("(5) Learn IR Code (UIRT-Struct Format)");
                Console.WriteLine("(6) Turn BlinkOnReceive {0}", mc.BlinkOnReceive ? "off" : "on");
                Console.WriteLine("(7) Turn BlinkOnTransmit {0}", mc.BlinkOnTransmit ? "off" : "on");
                Console.WriteLine("(8) Turn GenerateLegacyCodesOnReceive {0}", mc.GenerateLegacyCodesOnReceive ? "off" : "on");
                Console.WriteLine("(x) Exit");
                Console.WriteLine("---------------------------------------");

                Console.WriteLine("Press a key...");
                toDo = Console.ReadLine();
            } while(toDo == String.Empty);

            switch(toDo[0])
            {
                case '1':
                    Console.WriteLine("Transmitting IR Code (blocking)...");
                    try
                    {
                        mc.Transmit(irCode, transmitFormat, 10, TimeSpan.Zero);
                    }
                    catch(Exception ex)
                    {
                        Console.WriteLine("*** ERROR calling Transmit! ***");
                        throw;
                    }
                    Console.WriteLine("...Returned from call (Done)!");
                break;

                case '2':
                    using (ManualResetEvent waitEvent = new ManualResetEvent(false))
                    {
                        mc.TransmitCompleted += new UsbUirt.Controller.TransmitCompletedEventHandler(mc_TransmitCompleted);
                        Console.WriteLine("\nTransmitting IR Code (non-blocking)...");
                        try
                        {
                            mc.TransmitAsync(irCode, transmitFormat, 10, TimeSpan.Zero, waitEvent);
                            Console.WriteLine("...Returned from call...");
                            if (waitEvent.WaitOne(5000, false))
                            {
                                Console.WriteLine("...IR Transmission Complete!");
                            }
                            else
                            {
                                Console.WriteLine("*** ERROR: Timeout error waiting for IR to finish!");
                            }
                        }
                        catch(Exception ex)
                        {
                            Console.WriteLine("*** ERROR calling TransmitAsync! ***");
                            throw;
                        }
                        finally
                        {
                            mc.TransmitCompleted -= new UsbUirt.Controller.TransmitCompletedEventHandler(mc_TransmitCompleted);
                        }
                    }
                    break;

                case '3':
                    TestLearn(mc, CodeFormat.Pronto, LearnCodeModifier.None);
                    break;

                case '4':
                    TestLearn(mc, CodeFormat.Uuirt, LearnCodeModifier.None);
                    break;

                case '5':
                    TestLearn(mc, CodeFormat.Uuirt, LearnCodeModifier.ForceStruct);
                    break;

                case '6':
                    mc.BlinkOnReceive = ! mc.BlinkOnReceive;
                    break;

                case '7':
                    mc.BlinkOnTransmit = ! mc.BlinkOnTransmit;
                    break;

                case '8':
                    mc.GenerateLegacyCodesOnReceive = ! mc.GenerateLegacyCodesOnReceive;
                    break;

                case 'x':
                    return false;

                default:
                    break;
            }
            return true;
        }