Skip to content

Commit 945139e

Browse files
committed
force message init on decoder in case address is missed. fixed threading / invoke on grid update
1 parent b45714f commit 945139e

2 files changed

Lines changed: 22 additions & 13 deletions

File tree

Pocsag.Plugin/PocsagControl.cs

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
namespace Pocsag.Plugin
22
{
33
using SDRSharp.Common;
4+
using System;
45
using System.ComponentModel;
56
using System.Windows.Forms;
67

@@ -45,19 +46,26 @@ public PocsagControl(ISharpControl control)
4546

4647
private void MessageReceived(Pocsag.Message message)
4748
{
48-
//int firstDisplayed = this.dataGridView1.FirstDisplayedScrollingRowIndex;
49-
//int displayed = this.dataGridView1.DisplayedRowCount(true);
50-
//int lastVisible = (firstDisplayed + displayed) - 1;
51-
//int lastIndex = this.dataGridView1.RowCount - 1;
52-
53-
this.bindingList.Add(message);
54-
55-
//if (lastVisible == lastIndex)
56-
//{
57-
// this.dataGridView1.FirstDisplayedScrollingRowIndex = firstDisplayed + 1;
58-
//}
59-
60-
//this.dataGridView1.FirstDisplayedScrollingRowIndex = this.messages.Count - 1;
49+
if (this.InvokeRequired)
50+
{
51+
this.BeginInvoke(
52+
new Action<Pocsag.Message>(
53+
(message) =>
54+
{
55+
int firstDisplayed = this.dataGridView1.FirstDisplayedScrollingRowIndex;
56+
int displayed = this.dataGridView1.DisplayedRowCount(true);
57+
int lastVisible = (firstDisplayed + displayed) - 1;
58+
int lastIndex = this.dataGridView1.RowCount - 1;
59+
60+
this.bindingList.Add(message);
61+
62+
if (lastVisible == lastIndex)
63+
{
64+
this.dataGridView1.FirstDisplayedScrollingRowIndex = firstDisplayed + 1;
65+
}
66+
}),
67+
new object[] { message });
68+
}
6169
}
6270
}
6371
}

Pocsag/Decoder.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public Decoder(int baud, int sampleRate, Action<Message> messageReceived)
4444
this.FrameIndex = -1;
4545
this.CodeWordPosition = -1;
4646

47+
this.QueueCurrentMessage();
4748
}
4849

4950
private uint GetBufferValue()

0 commit comments

Comments
 (0)