Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

MVVM in serial communication scenario

$
0
0

Hello all,

in my scenario I've  c# library (DLL) that implements my protocol functions, as following:

public Read(...)
{
  ..
  ..
  myThread = new Thread(this.TraceThreadProc);
  ..
  ..
  myThread.Start(tParams);
}
protected override void TraceThreadProc(object data)
{
  ..
  ..
  do
  {
    ..
    ..
    // Call event on client program about every 20msec
    OnReadFrameReady(..)
  }
  while (stopRequest == false);
  ..
  // Communicate to client that read is terminated !
  OnReadComplete(..);
}

In my MainWindowViewModel, receive for every frame, one event from DLL protocol that contains different field as (IdFrame, Variable1, Variable 2, ... Variable N°).

I want display this data into a DataGrid, that have a maximum number of rows (for example 20, one row in one data contains in event receveid); How can I stored this data into ObservableCollection ? (believe thread-safe, because the events run in a different thread). This collection must be limited to a fixed number element.

Is it possible remove every row added in datagrid the first row to obtain a scroll effect ?

Stefano



Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>