polling data source c# using threads
int delay = 1;
var cancellationTokenSource = new CancellationTokenSource();
var token = cancellationTokenSource.Token;
var listener = Task.Factory.StartNew(() =>
{
while (true)
{
// poll source
Thread.Sleep(delay);
if (token.IsCancellationRequested)
break;
}
// cleanup, e.g. close connection
}, token, TaskCreationOptions.LongRunning, TaskScheduler.Default);
Also in C#:
- read embedded resource c# xml
- c# how to add newline on text box
- c# mongodb update multiple fields
- abstract class c#
- mvc write to console
- get web config key value in c# razor view
- asp.net tag helper checkbox
- c# check if string is all numbers
- texture to image unity
- unity check when clicked on object
- create dropdown in datatable c# dynamically
- eager loading vs lazy loading c#
- unity t-flip flop
- blazor wasm routable page in separate project
- c# reflection create generic type
- converting letter to ascii
- count number of enum values C#
- c sharp substring
- get out of foreach statement c#
- visual studio C# hintergrund bild ändern
- how to add a list to observablecollection in c#
- how to change the title of the console in c#
- how to detected WindowCloseEvent in other window wpf
- json tiers dot in name c#