I have a background worker thread receiving UDP data from a server. The background thread wraps the data and pushes it to the UI thread via the Progress changed UserState. After receiving a bunch of data the
program crashes. Here is a code snippet:
privatevoid backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
BackgroundWorker worker = sender as BackgroundWorker;
privatevoid backgroundWorker1_ProgressChanged(object sender, ProgressChangedEventArgs e)
ob o = e.UserState as ob;
AddRow(o.ip, o.port, o.data);
I couldn't download your source as it requires a password.
Anyway I am assuming that you are binding the data to a control so that you can see it as it comes in. Then you will have problems with the background thread changing things while the control is trying to access the data.
Rather than use DataSet, it would seem better to use ConcurrentQueue, which is thread safe.