HamBook – Diff between revs 5 and 7

Subversion Repositories:
Rev:
Show entire fileIgnore whitespace
Rev 5 Rev 7
Line 8... Line 8...
8 using System.Threading; 8 using System.Threading;
9 using System.Threading.Tasks; 9 using System.Threading.Tasks;
10 using Serilog; 10 using Serilog;
11 using HamBook.Properties; 11 using HamBook.Properties;
12 using Serilog.Events; 12 using Serilog.Events;
-   13 using System.Media;
-   14 using System.Reflection;
Line 13... Line 15...
13   15  
14 namespace HamBook 16 namespace HamBook
15 { 17 {
16 public class BandScan 18 public class BandScan
17 { 19 {
Line 18... Line 20...
18 private CancellationTokenSource _scanningCancellationTokenSource; 20 private CancellationTokenSource _scanningCancellationTokenSource;
19   -  
20 private CancellationToken _scanningCancellationToken; 21  
21 private Task _aiTask; 22 private CancellationToken _scanningCancellationToken;
22 private CatAssemblies _catAssemblies; 23 private CatAssemblies _catAssemblies;
23 private int _minFrequency; 24 private int _minFrequency;
24 private int _maxFrequency; 25 private int _maxFrequency;
Line 44... Line 45...
44 { 45 {
45 _scanningCancellationTokenSource.Cancel(); 46 _scanningCancellationTokenSource.Cancel();
Line 46... Line 47...
46 47
Line 47... Line -...
47 } -  
48   -  
49 if(_aiTask != null) -  
50 { -  
51 _aiTask.Wait(); -  
52 } 48 }
53   49  
Line 54... Line 50...
54 _scanningCancellationTokenSource = new CancellationTokenSource(); 50 _scanningCancellationTokenSource = new CancellationTokenSource();
55 _scanningCancellationToken = _scanningCancellationTokenSource.Token; 51 _scanningCancellationToken = _scanningCancellationTokenSource.Token;
Line 61... Line 57...
61 { 57 {
62 if (_scanningCancellationTokenSource != null) 58 if (_scanningCancellationTokenSource != null)
63 { 59 {
64 _scanningCancellationTokenSource.Cancel(); 60 _scanningCancellationTokenSource.Cancel();
65 } 61 }
66   -  
67 if (_aiTask != null) -  
68 { -  
69 _aiTask.Wait(); -  
70 } -  
71 } 62 }
Line 72... Line 63...
72   63  
73 private async Task Scan(int step, int pause) 64 private async Task Scan(int step, int pause)
74 { 65 {
Line 90... Line 81...
90   81  
91 #pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed 82 #pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
92 Task.Delay(TimeSpan.FromSeconds(pause)).ContinueWith(_ => taskCompletionSource.TrySetResult(true), _scanningCancellationToken); 83 Task.Delay(TimeSpan.FromSeconds(pause)).ContinueWith(_ => taskCompletionSource.TrySetResult(true), _scanningCancellationToken);
Line -... Line 84...
-   84 #pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
-   85  
-   86 using (var soundPlayer = new SoundPlayer(Assembly.GetExecutingAssembly().GetManifestResourceStream("HamBook.Effects.pot.wav")))
93 #pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed 87 {
-   88 soundPlayer.Play();
Line 94... Line 89...
94   89 _catAssemblies.CatSet<int>("FA", new object[] { _currentFrequency });
Line 95... Line 90...
95 _catAssemblies.CatSet<int>("FA", new object[] { _currentFrequency }); 90 }
96   91