Created
April 7, 2020 11:07
-
-
Save mrtank/124ee282c33dcb32c734af4874772a14 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public int counter { get; set; } | |
public async void test() | |
{ | |
var uiThreadScheduler = TaskScheduler.FromCurrentSynchronizationContext(); | |
while(true) | |
{ | |
Task backgroundTask = Task.Run (async () => { | |
await Task.Delay(300); | |
Interlocked.Increment(ref this.counter); | |
}); | |
backgroundTask.ContinueWith(() => { textBox.Text = counter.ToString(); }, uiThreadScheduler); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment