I've tried stopping the dataflow, and then scrolling but this gives the same problem.
Also the scrollbar arrows are not drawn.
- public partial class SnifferPanel : UserControl
- {
- public bool running = false;
- DataTable d;
- public SnifferPanel()
- {
- d = new DataTable();
- d.Columns.Add("Source");
- d.Columns.Add("Destination");
- d.Columns.Add("UID");
- d.Columns.Add("Index");
- d.Columns.Add("Mode");
- d.Columns.Add("Data");
- InitializeComponent();
- BindingSource b = new BindingSource();
- b.DataSource = d;
- dataGridViewSniffer.DataSource = b;
- }
- public void newData(Emulator.Modulemanager.RS485Data data)
- {
- if (running)
- {
- dataGridViewSniffer.SuspendLayout();
- string[] da = { data.Address, data.Address, data.Uid, data.Index, data.Mode, data.Data };
- d.Rows.Add(da);
- dataGridViewSniffer.ResumeLayout();
- }
- }
- }
The newData function is called from a class that handles the incoming data, this class runs in a seperate thread.
I hope someone here can help me out.
edit: Wow, my code looks horrible. Can anyone tell me how to properly align code on the forum?
Sam HobbsPosted Mar 18, 2010, 3:50 PM
at the end of lines to make new lines. You need to do that before pasting the code but the
must be inserted in HTML view. The tab character is not so easy to do in HTML and this web site software does not have any assistance for that.
My guess is that you have done somethig to turn off the warnings that C# provides telling you to not do what you are doing, so now you are getting a more serious problem and you don't understand why. It is clearly documented that controls are not thread-safe. So are you calling newData from the other thread without using an Invoke or something else to transfer the data from thread to thread? If so, then are you using something to turn off the warning to not do that?
Sam HobbsPosted Mar 19, 2010, 8:27 AM
ruben laureysPosted Mar 19, 2010, 4:05 AM
Thank you very much!