MetroFramework.Animation.DelayedCall.Register C# (CSharp) Method

Register() protected static method

protected static Register ( DelayedCall dc ) : void
dc DelayedCall
return void
        protected static void Register(DelayedCall dc)
        {
            lock (dcList)
            {
                if (!dcList.Contains(dc))
                    dcList.Add(dc);
            }
        }

Usage Example

        protected static void PrepareDCObject(DelayedCall dc, int milliseconds, bool async)
        {
            if (milliseconds < 0)
            {
                throw new ArgumentOutOfRangeException("milliseconds", "The new timeout must be 0 or greater.");
            }
            dc.context = null;
            if (!async)
            {
                dc.context = SynchronizationContext.Current;
                if (dc.context == null)
                {
                    throw new InvalidOperationException("Cannot delay calls synchronously on a non-UI thread. Use the *Async methods instead.");
                }
            }
            if (dc.context == null)
            {
                dc.context = new SynchronizationContext();
            }
            dc.timer = new System.Timers.Timer();
            if (milliseconds > 0)
            {
                dc.timer.Interval = (double)milliseconds;
            }
            dc.timer.AutoReset = false;
            DelayedCall delayedCall = dc;

            dc.timer.Elapsed += new ElapsedEventHandler(delayedCall.Timer_Elapsed);
            DelayedCall.Register(dc);
        }
All Usage Examples Of MetroFramework.Animation.DelayedCall::Register