Esempio n. 1
0
        /// <summary>
        /// Initializes a new instance of the Timer class with the user
        /// supplied callback and state information, timer period, resolution,
        /// and timer mode.
        /// </summary>
        /// <param name="callback">
        /// A TimerCallback delegate representing a method to be executed when
        /// a timer event occurs.
        /// </param>
        /// <param name="state">
        /// An object containing information to be used by the callback method,
        /// or a null reference.
        /// </param>
        /// <param name="period">
        /// The time between timer events in milliseconds.
        /// </param>
        /// <param name="resolution">
        /// The timer resolution in milliseconds.
        /// </param>
        /// <param name="mode">
        /// The timer mode.
        /// </param>
        public Timer(TimerCallback callback, object state, int period,
                     int resolution, TimerMode mode)
        {
            //
            // Initialize fields.
            //

            this.callback    = callback;
            this.state       = state;
            timeProcPeriodic = new TimeProc(OnTimerPeriodicEvent);
            timeProcOneShot  = new TimeProc(OnTimerOneShotEvent);
            Mode             = mode;
            Period           = period;
            Resolution       = resolution;
            running          = false;
        }
Esempio n. 2
0
        public static uint timeSetEvent(uint uDelay, uint uResolution, TimeProc lpTimeProc, IntPtr dwUser, uint fuEvent)
        {
            if (timer != null)
            {
                timer.Stop();
                timer.Dispose();
            }

            timer           = new Timer(uResolution);
            timer.Elapsed  += (object source, ElapsedEventArgs e) => lpTimeProc(1, 0, 0, 0, 0);
            timer.Enabled   = true;
            timer.AutoReset = true;
            timer.Start();

            return(1);
        }
Esempio n. 3
0
        public void Start()
        {
            var frame = CaptureFrame(true);

            _ringBuffer.Size = _config.RingBuffer;
            if (_config.RingBuffer == 0)
            {
                SaveFrame(frame);
            }
            else
            {
                AddFrame(frame);
            }
            var dummy = 0u;

            _timeProc = TimerCallback; // avoid to be collected by GC
            _timerId  = timeSetEvent(_config.Interval == 0 ? 1u : (uint)_config.Interval, 0, _timeProc, ref dummy,
                                     TIME_PERIODIC | TIME_KILL_SYNCHRONOUS);
        }
Esempio n. 4
0
 private static extern int timeSetEvent(int delay, 
                                        int resolution,
                                        TimeProc proc, 
                                        int user, 
                                        int mode);
Esempio n. 5
0
        // Initialize timer with default values.
        void Initialize()
        {
            this.mode = TimerMode.PERIODIC;
            this.interval = Capabilities.intervalMin;
            this.resolution = 1;

            running = false;
            disposed = false;
            synchronizingObject = null;
            site = null;

            timeProcPeriodic = new TimeProc(TimerPeriodicEventCallback);
            timeProcOneShot = new TimeProc(TimerOneShotEventCallback);
            tickRaiser = new EventRaiser(OnTick);
        }
Esempio n. 6
0
        /// <summary>
        /// Initializes a new instance of the Timer class with the user 
        /// supplied callback and state information, timer period, resolution,
        /// and timer mode.
        /// </summary>
        /// <param name="callback">
        /// A TimerCallback delegate representing a method to be executed when 
        /// a timer event occurs. 
        /// </param>
        /// <param name="state">
        /// An object containing information to be used by the callback method, 
        /// or a null reference.
        /// </param>
        /// <param name="period">
        /// The time between timer events in milliseconds.
        /// </param>
        /// <param name="resolution">
        /// The timer resolution in milliseconds.
        /// </param>
        /// <param name="mode">
        /// The timer mode.
        /// </param>
        public Timer(TimerCallback callback, object state, int period, 
            int resolution, TimerMode mode)
        {
            //
            // Initialize fields.
            //

            this.callback = callback;
            this.state = state;
            timeProcPeriodic = new TimeProc(OnTimerPeriodicEvent);
            timeProcOneShot = new TimeProc(OnTimerOneShotEvent);
            Mode = mode;
            Period = period;
            Resolution = resolution;
            running = false;
        }
Esempio n. 7
0
 internal static extern int timeSetEvent(int delay, int resolution, TimeProc proc, ref UIntPtr user, int mode);
 public static extern uint timeSetEvent(uint uDelay, uint uResolution, TimeProc lpTimeProc, IntPtr dwUser, uint fuEvent);
Esempio n. 9
0
			extern internal static MMRESULT timeSetEvent(uint uDelay, uint uResolution, TimeProc lpTimeProc, IntPtr dwUser, TIME_FLAGS fuEvent);
        // Initialize timer with default values.
        private void Initialize()
        {
            this.mode = TimerMode.Periodic;
            this.period = Capabilities.periodMin;
            this.resolution = 1;

            this.running = false;

            this.timeProcPeriodic = this.TimerPeriodicEventCallback;
            this.timeProcOneShot = this.TimerOneShotEventCallback;
            this.tickRaiser = this.OnTick;
        }
Esempio n. 11
0
        public CWX(Console c)
        {
            InitializeComponent();
            this.DoubleBuffered = true;
            console = c;

            clear_keys();

            txt1.Text = "### test de vk1aa";
            txt2.Text = "cq cq test yt7pwr test";
            txt3.Text = "5nn stx";
            txt4.Text = "vk1aa de yt7pwr";
            txt5.Text = "cq cq cq de yt7pwr +k";
            txt6.Text = "qrz?";
            txt7.Text = "?";
            txt8.Text = "agn";
            txt9.Text = "yu1lm";
            cwxwpm = 20;
            tpause = 100;
            RestoreSettings();
            cwxwpm = (int)udWPM.Value;
            tpause = (int)udDelay.Value * 1000;
            if (tpause < 1) tpause = tel;
            ttdel = (int)udDrop.Value;
            pttdelay = (int)udPtt.Value;
            udDrop.Minimum = pttdelay + pttdelay / 2;
            timeProcPeriodic = new TimeProc(TimerPeriodicEventCallback);
            setup_timer();
            load_alpha();
            // build the mbits array from a2m2
            build_mbits2();

            stopThreads = false;

            Thread keyFifoThread = new Thread(new ThreadStart(keyboardFifo));
            keyFifoThread.Name = "keyboard fifo pop thread";
            keyFifoThread.IsBackground = true;					// if app closes, kill this thread
            keyFifoThread.Priority = ThreadPriority.Normal;
            keyFifoThread.Start();

            Thread keyDisplayThread = new Thread(new ThreadStart(keyboardDisplay));
            keyDisplayThread.Name = "keyboard edit box handler thread";
            keyDisplayThread.IsBackground = true;					// if app closes, kill this thread
            keyDisplayThread.Priority = ThreadPriority.Normal;
            keyDisplayThread.Start();
        }
Esempio n. 12
0
 private static extern uint timeSetEvent(uint delay, uint resolution, TimeProc timeProc,
                                         ref uint user, uint eventType);
Esempio n. 13
0
        TimeProc timerProc;             //timer callback func

        public MidiTimer()
        {
            timerProc = timerCallback;          //set callback func
        }
Esempio n. 14
0
        /// <summary>
        /// Starts the timer.
        /// </summary>
        /// <exception cref="ObjectDisposedException">
        /// The timer has already been disposed.
        /// </exception>
        /// <exception cref="TimerStartException">
        /// The timer failed to start.
        /// </exception>
        public void Start(TimeProc timerCallback)
        {
            #region Require

            if (disposed)
            {
                throw new ObjectDisposedException("MultimediaTimer");
            }

            #endregion

            #region Guard

            if (IsRunning)
            {
                return;
            }

            #endregion

            // If the periodic event callback should be used.
            if (Mode == TimerMode.Periodic)
            {
                // Create and start timer.
                timerID = timeSetEvent(Period, Resolution, timerCallback, 0, (int)Mode);
            }
                // Else the one shot event callback should be used.
            else
            {
                // Create and start timer.
                timerID = timeSetEvent(Period, Resolution, timerCallback, 0, (int)Mode);
            }

            // If the timer was created successfully.
            if (timerID != 0)
            {
                running = true;

                if (SynchronizingObject != null && SynchronizingObject.InvokeRequired)
                {
                    SynchronizingObject.BeginInvoke(
                        new EventRaiser(OnStarted),
                        new object[] { EventArgs.Empty });
                }
                else
                {
                    OnStarted(EventArgs.Empty);
                }
            }
            else
            {
                throw new TimerStartException("Unable to start multimedia MultimediaTimer.");
            }
        }
Esempio n. 15
0
        private void Initialize()
        {
            this.mode = Mode.Periodic;
            this.period = Capabilities.periodMin;
            this.resolution = 1;

            running = false;

            timeProcPeriodic = new TimeProc(TimerPeriodicEventCallback);
            timeProcOneShot = new TimeProc(TimerOneShotEventCallback);
            tickRaiser = new EventRaiser(OnTick);
        }
Esempio n. 16
0
		public CWX(Console c)
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			console = c;

			//
			// TODO: Add any constructor code after InitializeComponent call
			//

			txtdummy1.Hide();
			clear_keys();

			txt1.Text = "### test de w5sxd/b el29ep.$$\"";
			txt2.Text = "cq cq test w5sxd test";
			txt3.Text = "5nn stx";
			txt4.Text = "k5sdr de w5sxd (";
			txt5.Text = "cq cq cq de w5sxd w5sxd w5sxd +k";
			txt6.Text = "The quick brown fox jumped over the lazy dog. 0123456789 ";
			txt7.Text = "?";
			txt8.Text = "agn";
			txt9.Text = "n6vs";

			//RestoreSettings();
			Common.RestoreForm(this, "CWX", true);

			//		cwxwpm = 20;
			//		udWPM.Value = cwxwpm;
			cwxwpm = (int)udWPM.Value;

			tpause = (int)udDelay.Value * 1000;
			if (tpause < 1) tpause = tel;
			ttdel = (int)udDrop.Value;
			pttdelay = (int)udPtt.Value;
			//udDrop.Minimum = pttdelay + pttdelay/2;



//			RestoreSettings();

#if(CWX_DEBUG)
			Debug.WriteLine("CWX entry");
#endif

			timeProcPeriodic = new TimeProc(TimerPeriodicEventCallback);
			setup_timer();
			load_alpha();
			// build the mbits array from a2m2
			build_mbits2();

			stopThreads = false;

			Thread keyFifoThread = new Thread(new ThreadStart(keyboardFifo));
			keyFifoThread.Name = "keyboard fifo pop thread";
			keyFifoThread.IsBackground = true;					// if app closes, kill this thread
			keyFifoThread.Priority = ThreadPriority.Normal;
			keyFifoThread.Start();
			
			Thread keyDisplayThread = new Thread(new ThreadStart(keyboardDisplay));
			keyDisplayThread.Name = "keyboard edit box handler thread";
			keyDisplayThread.IsBackground = true;					// if app closes, kill this thread
			keyDisplayThread.Priority = ThreadPriority.Normal;
			keyDisplayThread.Start();

			Thread CATReadThread = new Thread(new ThreadStart(SendBufferMessage));
			CATReadThread.Name = "CAT Read Thread";
			CATReadThread.IsBackground = true;
			CATReadThread.Priority = ThreadPriority.Highest;
			CATReadThread.Start();

//			ttdel = 50;
		}
Esempio n. 17
0
 private static extern int timeSetEvent(int delay, int resolution,
                                        TimeProc proc, int user, int mode);
Esempio n. 18
0
 extern internal static MMRESULT timeSetEvent(uint uDelay, uint uResolution, TimeProc lpTimeProc, IntPtr dwUser, TIME_FLAGS fuEvent);