diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-04-13 03:41:41 +0300 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-04-13 03:41:41 +0300 |
| commit | 76ebe53d89a1b0cbf21d66dc9f26dc95cc7b3be9 (patch) | |
| tree | d1043332c085a2624187b77b37c63a37505cdad2 /Software/Visual_Studio/FSE/Tango.FSE.Common/FileSystem/FileSystemHandler.cs | |
| parent | d26e810aa206bf850622ded5a0da76293cb12f13 (diff) | |
| download | Tango-76ebe53d89a1b0cbf21d66dc9f26dc95cc7b3be9.tar.gz Tango-76ebe53d89a1b0cbf21d66dc9f26dc95cc7b3be9.zip | |
FSE TUP
Diffstat (limited to 'Software/Visual_Studio/FSE/Tango.FSE.Common/FileSystem/FileSystemHandler.cs')
| -rw-r--r-- | Software/Visual_Studio/FSE/Tango.FSE.Common/FileSystem/FileSystemHandler.cs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/FileSystem/FileSystemHandler.cs b/Software/Visual_Studio/FSE/Tango.FSE.Common/FileSystem/FileSystemHandler.cs index e74395ade..9cceb4fa3 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.Common/FileSystem/FileSystemHandler.cs +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/FileSystem/FileSystemHandler.cs @@ -14,6 +14,7 @@ namespace Tango.FSE.Common.FileSystem private FileSystemHandlerStatus _statusBeforePause; private System.Timers.Timer _transferRateTimer; private double _lastPosition; + private TaskCompletionSource<FileSystemHandlerStatus> _completionSource; public event EventHandler<FileSystemHandlerStatus> StatusChanged; @@ -93,6 +94,7 @@ namespace Tango.FSE.Common.FileSystem public FileSystemHandler(FileSystemHandlerType type, FileSystemItem fileSystemItem, String destination, Action abortAction) { + _completionSource = new TaskCompletionSource<FileSystemHandlerStatus>(); Type = type; FileSystemItem = fileSystemItem; Destination = destination; @@ -133,16 +135,19 @@ namespace Tango.FSE.Common.FileSystem { Status = FileSystemHandlerStatus.Failed; FailedException = exception; + _completionSource.SetException(exception); } internal void RaiseAborted() { Status = FileSystemHandlerStatus.Aborted; + _completionSource.SetException(new OperationCanceledException("File system operation aborted.")); } internal void RaiseCompleted() { Status = FileSystemHandlerStatus.Completed; + _completionSource.SetResult(Status); } public void Abort() @@ -150,5 +155,10 @@ namespace Tango.FSE.Common.FileSystem Status = FileSystemHandlerStatus.Aborted; _abortAction?.Invoke(); } + + public Task<FileSystemHandlerStatus> WaitForCompletion() + { + return _completionSource.Task; + } } } |
