AsyncInfiniteLoops.MainWindow.DoWorkPollingTask C# (CSharp) Method

DoWorkPollingTask() public method

public DoWorkPollingTask ( ) : void
return void
        void DoWorkPollingTask()
        {
            Task.Run(async () =>
            {
                while (true)
                {
                    // do the work in the loop
                    string newData = DateTime.Now.ToLongTimeString();

                    // marshal back over to the UI thread to update the UI
                    Dispatcher.Invoke(() => txtTicks.Text = "TASK - " + newData);

                    // don't run again for at least 200 milliseconds
                    await Task.Delay(200);
                }
            });
        }
        #endregion