Zzz – Diff between revs 2 and 4

Subversion Repositories:
Rev:
Only display areas with differencesIgnore whitespace
Rev 2 Rev 4
1 using System.Collections.Specialized; 1 using System.Collections.Specialized;
2 using System.Threading; 2 using System.Threading;
3 using System.Windows.Forms; 3 using System.Windows.Forms;
4 using Zzz.Utilities; 4 using Zzz.Utilities;
5 using Zzz; 5 using Zzz;
6   6  
7 namespace Zzz 7 namespace Zzz
8 { 8 {
9 public partial class LogViewForm : Form 9 public partial class LogViewForm : Form
10 { 10 {
11 private readonly MainForm _mainForm; 11 private readonly MainForm _mainForm;
12   12  
13 private readonly LogMemorySink _memorySink; 13 private readonly LogMemorySink _memorySink;
-   14 private readonly object _memorySinkLock;
14   15  
15 public LogViewForm() 16 public LogViewForm()
16 { 17 {
17 InitializeComponent(); 18 InitializeComponent();
18 } 19 }
19   20  
20 public LogViewForm(MainForm mainForm) : this() 21 public LogViewForm(MainForm mainForm) : this()
21 { 22 {
22 _mainForm = mainForm; 23 _mainForm = mainForm;
23 _mainForm.MemorySinkEnabled = true; 24 _mainForm.MemorySinkEnabled = true;
24 } 25 }
25   26  
26 public LogViewForm(MainForm mainForm, LogMemorySink memorySink) : 27 public LogViewForm(MainForm mainForm, LogMemorySink memorySink, object memorySinkLock) :
27 this(mainForm) 28 this(mainForm)
28 { 29 {
29 _memorySink = memorySink; 30 _memorySink = memorySink;
-   31 _memorySinkLock = memorySinkLock;
30 _memorySink.Events.CollectionChanged += Events_CollectionChanged; 32 _memorySink.Events.CollectionChanged += Events_CollectionChanged;
31 } 33 }
32   34  
33 /// <summary> 35 /// <summary>
34 /// Clean up any resources being used. 36 /// Clean up any resources being used.
35 /// </summary> 37 /// </summary>
36 /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> 38 /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
37 protected override void Dispose(bool disposing) 39 protected override void Dispose(bool disposing)
38 { 40 {
39 if (disposing && components != null) 41 if (disposing && components != null)
40 { 42 {
41 components.Dispose(); 43 components.Dispose();
42 } 44 }
43   -  
44 _memorySink.Events.CollectionChanged -= Events_CollectionChanged; -  
45   45  
-   46 _mainForm.MemorySinkEnabled = false;
-   47  
-   48 lock (_memorySinkLock)
-   49 {
46 _mainForm.MemorySinkEnabled = false; 50 _memorySink.Events.CollectionChanged -= Events_CollectionChanged;
-   51 _memorySink.Clear();
47 _memorySink.Clear(); 52 }
48   53  
49 base.Dispose(disposing); 54 base.Dispose(disposing);
50 } 55 }
51   56  
52 private void Events_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) 57 private void Events_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
53 { 58 {
54 switch (e.Action) 59 switch (e.Action)
55 { 60 {
56 case NotifyCollectionChangedAction.Add: 61 case NotifyCollectionChangedAction.Add:
57 foreach (var item in e.NewItems) 62 foreach (var item in e.NewItems)
58 { 63 {
59 var line = (string)item; 64 var line = (string)item;
60   65  
61 textBox1.InvokeIfRequired(textbox => { textbox.AppendText(line); }); 66 textBox1.InvokeIfRequired(textbox => { textbox.AppendText(line); });
62 } 67 }
63   68  
64 break; 69 break;
65 } 70 }
66 } 71 }
67   72  
68 private void LogViewForm_Load(object sender, System.EventArgs e) 73 private void LogViewForm_Load(object sender, System.EventArgs e)
69 { 74 {
70 Utilities.WindowState.FormTracker.Track(this); 75 Utilities.WindowState.FormTracker.Track(this);
71 } 76 }
72 } 77 }
73 } 78 }
74   79  
75
Generated by GNU Enscript 1.6.5.90.
80
Generated by GNU Enscript 1.6.5.90.
76   81  
77   82  
78   83