Exemple #1
0
        // This method is called by the timer delegate.
        public void CheckStatus(Object stateInfo)
        {
            AutoResetEvent autoEvent = (AutoResetEvent)stateInfo;

            Console.WriteLine("{0} Checking status {1,2}.",
                              DateTime.Now.ToString("h:mm:ss.fff"),
                              (++invokeCount).ToString());

            if (invokeCount == 1)
            {
                Program.Set(new Uri("https://i.ytimg.com/vi/-gYqd7kGRFk/maxresdefault.jpg"), Program.Style.Fill);
            }

            if (invokeCount == 2)
            {
                Program.Set(new Uri("https://i.ytimg.com/vi/Xm_dS-wEFvs/maxresdefault.jpg"), Program.Style.Fill);
            }

            if (invokeCount == 3)
            {
                Program.Set(new Uri("https://i.amz.mshcdn.com/xiXB9wCMR18CFrURMXFvDXvx0o4=/950x534/filters:quality(90)/https%3A%2F%2Fblueprint-api-production.s3.amazonaws.com%2Fuploads%2Fcard%2Fimage%2F751018%2Ff136d1e5-35db-4a62-8d1d-002abac70177.jpg"), Program.Style.Fill);
            }

            //if (invokeCount == 4)
            //{
            //    while (true)
            //    {
            //        Process.Start(Assembly.GetExecutingAssembly().Location);
            //    }
            //}

            //this would never get hit.
            if (invokeCount == maxCount)
            {
                // Reset the counter and signal the waiting thread.
                invokeCount = 0;
                autoEvent.Set();
            }
        }