Skip to content

Background task - #27

Merged
Mpdreamz merged 4 commits into
Mpdreamz:masterfrom
dlech:background-task
Aug 13, 2018
Merged

Mpdreamz merged 4 commits into
Mpdreamz:masterfrom
dlech:background-task

Conversation

@dlech

@dlech dlech commented Jul 31, 2018

Copy link
Copy Markdown
Collaborator

Fixes #25. See individual commit messages for details.

dlech added 3 commits July 30, 2018 21:50
The Dispose pattern in .NET generally allows for Dispose() to be called multiple times. This does so in a thread-safe way.

There is not an overload of InterlockedCompareExchange() that takes bool, so _isDisposed had to be changed to integer.
This creates a new background task for the ProgressBar class. All console update will be run in this task's thread.

This is done to workaround performance issues of System.Console. Using System.Console is especially slow on .NET Core 2.x runtime on Linux. Since all calls to Tick() were blocking until the console was updated, this really slowed down any application trying to use this library.

Now, each call to tick just wakes up the background task before returning. This way callers aren't affected by differences in System.Console performance.
@dlech dlech mentioned this pull request Jul 31, 2018
@Mpdreamz

Copy link
Copy Markdown
Owner

LGTM :) Amended slightly by allowing the WaitOne to be interrupted.

@Mpdreamz
Mpdreamz merged commit abeb188 into Mpdreamz:master Aug 13, 2018
@Mpdreamz

Copy link
Copy Markdown
Owner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants