I am creating a small Windows application application that will receive messages from a background thread and then add them to a list on the menu. Will give the form I DataSource DataGrid view message list ( like At this time, messages are accumulating, but I can not get DataGridView to deliver these messages, as they are generated. Here I have given a summary of the approach used. 1. Start setting primarily binding and beginning the message 2. Add process to received messages and internal list 3. Refresh to main thread Can anyone suggest how I can reflect the changes that occur in the UI. Note: I have also tried to use invalid method and reset method. I list a switch Tried to do Event by changing the list in your main form and you're good to go. list & lt; message & gt; ) on the form >
Internal Home (IMages Dispatcher Message Dispatcher, IMSJP Publisher Message Publisher) {Initialization (); _messageEntries = New list & lt; Message & gt; (); BindToMessageEntriesList (); _messageDispatcher = messageDispatcher; _messageDispatcher.OnMessageReceived + = MessageDispatcher_OnMessageReceived; _messageDispatcher.Start (); } Private Zero BindToMessageEntriesList () {MessageIntegrated.Data Source = _messageEntries; }
Private Zero MessageDispatcher_OnMessageReceived (message message) {lock (_logEntries) {_messageEntries.Add (message); } Var cb = new refreshlist callback (RefreshView); This.Invoke (CB); }
Private Zero Refresh View () {MessageEntriesGrid.Refresh (); }
ObsavableCollection
list & lt; Message & gt; () for a custom class and
binding list and attach your
message dispatcher to it. Example
Public class message list: bidding list and message; Message & gt; {}
Comments
Post a Comment